Query and route parameters — Lesson overview
Chegg Skills Lesson 5 (Node and Express): read three request inputs—path params, query string, and body—and use each in the right place in controllers and services.
Learn: Lesson 5 in the Node and Express unit introduces the three ways HTTP sends data into your API. Route parameters identify which resource (req.params). Query parameters optional filters (req.query). The body carries JSON on POST/PUT (req.body). Controllers read all three; routers only declare path parameter names in the URL pattern.
Course example
// Path parameter (router defines :userId)
// GET /users/42 -> req.params.userId === "42"
// Query string (optional filters)
// GET /pastes?sort=desc&limit=5 -> req.query.sort, req.query.limit
// JSON body (POST/PUT, needs express.json())
// POST /users body: { "username": "ada" } -> req.body.username
Additional references & examples
- Express Router API
Router methods, route parameters, and mounting paths.
- Express req.params
Path parameters from the route pattern.
- Express req.query
Parsed query string parameters.