Express.js res.req Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Response

Definition

In Express.js, res.req holds a reference to the request object for the same HTTP cycle. In any handler, res.req === req is true.

It is the reverse of req.res. Prefer the req argument when you have it. Use res.req when a helper only receives res.

Syntax

Read res.req in your Express.js handler. Start with this line.

Express
res.req              // → Request (same as req)
res.req === req      // → true
req.res              // → Response (reverse link)
CallWhat it does
res.reqThe request paired with this response.
res.req === reqSame object identity check.
req.resReverse link from request to response.

Install with npm install express. Express sets this link for every request automatically.

Parameters

This Express.js property is read from the response — it has no call parameters.

Return Value

Reading res.req returns the same request object as the req argument for this cycle.

Express
function logMethod(res) {
  console.log(res.req.method);
}

Express.js Examples

Example — Confirm res.req Is the Same Object

Prove the identity check from the Express docs.

Express
const express = require('express');
const app = express();

app.get('/', (req, res) => {
  console.log(res.req === req); // true
  console.log(req.res === res); // true
  res.send('OK');
});

app.listen(3000);

How It Works

  1. Express links the pair. Before your handler, Express sets res.req = req.
  2. Strict equality. === compares object identity.
  3. One request. Reading res.req.method is the same as req.method.
  4. Takeaway. res.req is a back-pointer, not a copy.

Example — Prefer the req Argument

Normal route style — clearer than going through res.req.

Express
const express = require('express');
const app = express();

app.get('/who', (req, res) => {
  res.json({ method: req.method, path: req.path });
});

app.listen(3000);

How It Works

  1. Handler signature. Express passes (req, res).
  2. Use req directly. Read method and path from req.
  3. Send with res. res.json(...) finishes the response.
  4. No need for res.req. You already have req in scope.

Example — Helper That Only Receives res

When a shared function takes only the response, read the request via res.req.

Express
const express = require('express');
const app = express();

function attachRequestId(res) {
  const id = res.req.get('x-request-id') || 'none';
  res.set('X-Echo-Request-Id', id);
}

app.get('/ping', (req, res) => {
  attachRequestId(res);
  res.send('pong');
});

app.listen(3000);

How It Works

  1. Helper signature. attachRequestId(res) only takes the response.
  2. Reach the request. res.req.get(...) reads a request header.
  3. Set a response header. res.set(...) echoes the id back.
  4. Alternative. Passing (req, res) is often clearer — use that when you can.

Runtime Support

res.req is an Express.js response property. It runs on a Node.js server (Express 5 needs Node.js 18+). Browsers do not have this API.

✓ Server · Express 4 & 5

res.req

Works wherever Express runs: Node.js is the primary target. Bun and Deno can run many Express apps with compatibility layers. Not available in the browser.

Server Node.js runtime API
Node.js 18+ for Express 5 · 14+ typical for Express 4
Supported
Bun Express-compatible server apps
Supported
Deno Via npm compatibility / adapters
Supported
res.req Express on Node.js

Bottom line: Study and run these examples with Node.js and the express package. Copy a snippet into a local file and start the server with node.

Frequently Asked Questions

It is a property on the response object that points to the request for the same HTTP cycle. In a handler, res.req === req is true.
Prefer the req argument in routes. Use res.req when a helper only receives res.
req.res points from the request back to the response. Express sets both links automatically.
No. It is the same request object — a back-pointer, not a copy.
No. It is a server-side Express property.

Next: res.send()

Send strings, objects, and buffers as the HTTP response body.

res.send() tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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.

8 people found this page helpful