Putting IDs in query params (should be in the path) or putting filters in the body of a GET request (GET should not have a body). Also forgetting express.json so req.body is undefined for POSTs.
Route Params vs Query Params vs Body in Express
What is a common mistake with route params vs query params?
The answer
More FAQs in Route Params vs Query Params vs Body in Express
Route params identify a resource (in the path, required). Query params filter (after ?, optional). Body sends data for create/update (with express.json, larger). Use each for the right job.
When the data identifies a specific resource. /users/:id where id is required. Always a string. Convert to ObjectId or number when needed.
For optional filters, sorting, and pagination. /users?role=admin&limit=10. Always strings. Coerce when needed. Optional, so the endpoint works without them too.
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.