Grokking ExpressJS
0% completed
Query Parameters vs. Route Parameters
How should a client ask the bookstore API for book number 2, and how should it ask for only the classic novels under 10 dollars? Both requests carry data in the URL, but they carry it in different places. The book number is part of the path, /books/2, while the filter comes after a question mark, /books?genre=classic&maxPrice=10.
Express reads the first kind into req.params and the second kind into req.query. Both appeared briefly in earlier chapters. This lesson explains how each one is parsed in Express 5, what type its values have, and how to choose between them.
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%