Query strings appear after the ? symbol in a URL (for example, /products?category=books&sort=price&page=2). Express parses them automatically into an object on req.query.
When to Use Query Strings vs Route Params
- Use Route Params (
/users/:id) to identify a specific resource. - Use Query Strings (
?search=express&limit=10) for filtering, searching, sorting, and pagination.
ADVERTISEMENT