req is the incoming request (body, params, query, headers, cookies). res is the outgoing response (status, json, send, cookie, redirect). next passes control to the next middleware or handler, or to the error handler with next(err).
Request Handlers in Express: req, res, and next Explained
What are req, res, and next in Express?
The answer
More FAQs in Request Handlers in Express: req, res, and next Explained
Add app.use(express.json()) before routes, then read req.body. It is the parsed JSON object for any request with Content-Type: application/json.
Use res.cookie(name, value, options) before sending the response. For JWT, set httpOnly: true, secure: true, sameSite: 'lax'. Clear with res.clearCookie(name).
Call next(err) or throw an error. Express skips to the error-handling middleware (the one with four parameters: err, req, res, next).
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.