Request Handling for Expresss
Request handling in Express is reading input from a request and building a correct response. Input arrives in req.params, req.query, req.body and req.headers, and the handler responds with res.json, res.status and headers, validating the input first so that bad data produces a clear 4xx response.
Stage: Building APIs · Part of the Express roadmap · Last reviewed 19 November 2026
What to learn in Request Handling
- Read route parameters, query strings, headers and JSON bodies from the request object
- Validate input with a schema library and return a 400 response with useful details
- Choose correct status codes such as 201, 204, 400, 404 and 409
- Handle file uploads with multer and set limits on size and type
- Set response headers and cookies with attention to cache and security options
Request Handling interview questions
What is the difference between req.params and req.query?
req.params holds values captured from the path pattern, such as the id in /users/:id. req.query holds the parsed query string after the question mark, such as page and limit in /users?page=2. Both arrive as strings and need validation.
Why validate input on the server when the client already does?
Clients can be bypassed with tools like curl, so client checks are only convenience. The server must validate type, format and range of every input to prevent bad data, crashes and injection attacks.
Where Request Handling fits in the Express roadmap
Request Handling belongs to the Building APIs stage (beginner level). Real endpoints.
Other units in this stage
Back to the full Express roadmap