Express req Object

Beginner
⏱️ 10 min read
📚 Updated: May 2026
🎯 Core concept

What you’ll learn

  • How Express builds and exposes the req object.
  • Which commonly used properties to read in real handlers.
  • When to use headers, params, query, and body accessors.
  • How to safely validate request data before processing.

Common req properties and methods

javascript
req.method
req.path
req.params
req.query
req.body
req.get('Header-Name')
1

Read request data in one handler

javascript
app.post('/users/:id', function (req, res) {
  res.json({
    method: req.method,
    id: req.params.id,
    page: req.query.page,
    body: req.body
  });
});
2

Validate incoming request inputs

javascript
app.get('/items/:id', function (req, res) {
  var id = Number(req.params.id);
  if (!Number.isInteger(id)) return res.status(400).send('Invalid id');
  res.send('Item ' + id);
});

❓ FAQ

req is the incoming request object available in middleware and route handlers.
It contains request metadata such as method, path, params, query, body, headers, and more.
Express builds on Node's object and adds many convenience properties and methods.
Use req.params for route segments and req.query for query string values.
Yes. Treat body, params, query, and headers as untrusted input and validate before use.
Did you know?

The Express req object extends Node’s request object and centralizes URL, headers, body, params, query, and routing context.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

4 people found this page helpful