How does the Express request-response cycle work?
A request arrives, middlewares run in order (each can modify req, respond, or call next), the matched route handler runs, and the response leaves. Errors skip to the error handler at the end.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in The Express Request-Response Cycle Explained
req.body (after express.json), req.params (URL params), req.query (query string), req.headers, and req.cookies (with cookie-parser). The handler reads these and sends a response.
Each middleware can modify req (e.g., set req.user from JWT), send an early response (e.g., 401 if auth fails), or call next to continue to the next middleware or handler. Middlewares run in the order you add them.
If a middleware or handler throws, Express skips to the error handler. Register an error-handling middleware with four parameters (err, req, res, next) at the end of app.js. It catches errors from any middleware or handler in the chain.
Still have questions?
Browse all our FAQs or reach out to our support team
