Need Assistance?

support@tutorialshub.in

Routing Fundamentals

Query Strings (req.query)

ADVERTISEMENT
Express.js Free Lesson
5 min read
ADVERTISEMENT

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
Hi, I'm Tuby! Here to help you