How do I read JSON body in Express?
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.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Request Handlers in Express: req, res, and next Explained
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).
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
