Route parameters
Routes can have dynamic parameters, marked with :. They arrive in
req.params:
app.get("/products/:id", (req, res) => {
const id = req.params.id; // if the route is /products/5 -> "5"
res.json({ id });
});
The request body
In POST/PUT the data arrives in req.body:
app.post("/tasks", (req, res) => {
const title = req.body.title;
res.status(201).json({ id: 1, title });
});
REST in one line
A REST API models resources (users, products...) and uses the HTTP
method for the action: GET /products (list), GET /products/5 (view one),
POST /products (create), PUT /products/5 (update), DELETE /products/5
(delete).