MyInternships.in

Express.js & REST APIs

Node.js Express Introduction

Express is the most widely used Node web framework. It adds routing, middleware, request parsing and error handling on top of the http module, in a small and unopinionated package.


What is Express Introduction in Node.js?

Express is the most widely used Node web framework. It adds routing, middleware, request parsing and error handling on top of the http module, in a small and unopinionated package.

Express Introduction example

A minimal Express server
JavaScript
import express from 'express';

const app = express();
app.use(express.json());          // parse JSON request bodies

app.get('/api/jobs', (req, res) => {
  res.json([{ id: 1, title: 'Frontend Intern' }]);
});

app.post('/api/jobs', (req, res) => {
  const job = req.body;           // populated by express.json()
  res.status(201).json({ id: 2, ...job });
});

app.listen(3000, () => console.log('API on http://localhost:3000'));

How this works

express.json() is middleware that reads the request stream and parses it into req.body. Without it req.body is undefined — the most common Express beginner problem.

Key points to remember

  • Express 5 is the current major version and supports async handlers natively.
  • It is deliberately minimal — auth, validation and database access are yours to choose.
  • Alternatives: Fastify for speed, NestJS for structure, Hono for edge runtimes.

Common mistakes with Express Introduction

  • Forgetting express.json() and finding req.body undefined.
  • Registering routes after app.listen, so they never match.

Node.js Express Introduction— Interview Questions & FAQs

Why is req.body undefined in Express?+

The body-parsing middleware is missing. Add app.use(express.json()) before your routes, and make sure the client sends Content-Type: application/json.

Related Node.js Topics

Keep learning with these closely related lessons.

Ready to use your Node.js skills?

Find verified Node.js internships and fresher developer jobs across India.

Browse Node.js Internships