← Node.js & Express learning pathNode.js & Express · Module 6 of 10
Routing and request data
Read params, query strings and bodies to build REST endpoints.
📖 Key ideas
- Route params: /users/:id → req.params.id.
- Query strings: /search?q=js → req.query.q.
- Body JSON: app.use(express.json()) then req.body.
- REST: GET read, POST create, PUT/PATCH update, DELETE remove.
- Return proper status codes: 200, 201, 400, 404, 500.
💡 Real-life example: A URL is a postal address: params are the house number, the query string is a note on the envelope.
req.paramsValues from the path
req.queryValues after ?
req.bodyParsed request body
201Status for created