What is the difference between req.params, req.query, and req.body?

Answer

These three objects on the Express request contain data from different parts of the HTTP request. req.params: values from URL path segments defined as route parameters (:id in /users/:id). Always strings. req.query: values from the URL query string (?key=value). Always strings (or arrays for repeated keys). Available without middleware. req.body: data from the request body (JSON, form data). Only populated after body-parsing middleware runs (express.json() or express.urlencoded()). Can be any parsed type. In a request to POST /users/42?verbose=true with body {"name":"Alice"}: req.params.id = "42", req.query.verbose = "true", req.body.name = "Alice".