Complete the code to define a route that captures a user ID parameter.
app.get('/user/[1]', (req, res) => { res.send(`User ID is ${req.params.id}`); });
The colon : before id defines a route parameter in Express.
Complete the code to access the route parameter named 'postId'.
app.get('/post/:postId', (req, res) => { const postId = req.params.[1]; res.send(`Post ID: ${postId}`); });
req.params.id when the parameter is named postIdYou access the route parameter by its exact name, here postId.
Fix the error in the route to correctly capture the 'category' parameter.
app.get('/items/[1]', (req, res) => { res.send(`Category: ${req.params.category}`); });
The route parameter must start with a colon (:), so use ':category'.
Fill both blanks to define a route with two parameters and access them.
app.get('/[1]/:[2]', (req, res) => { res.send(`Category: ${req.params.category}, ID: ${req.params.id}`); });
The route path should be '/category/:id' to capture both parameters correctly.
Fill all three blanks to create a route with nested parameters and access them.
app.get('/[1]/:[2]/[3]/:commentId', (req, res) => { res.send(`Post: ${req.params.postId}, Comment: ${req.params.commentId}`); });
The route path should be '/posts/:postId/comments/:commentId' to capture both post and comment IDs.
