Notes:
-
In a URL, everything after the question mark (?) is considered the query string. a)
/api/movies/search?q=star wars
- Query parameter:
q=star wars
- In Express:
req.query.q
would be “star wars”
b)
/api/movies/search?title=inception&year=2010
- Two query parameters:
title=inception
andyear=2010
- In Express:
req.query.title
would be “inception”req.query.year
would be “2010”
c)
/api/movies/search?=matrix
(your original case)- Unnamed parameter with value “matrix”
- In Express:
req.query['']
would be “matrix”
d)
/api/movies/search?genre=action&sort=year&order=desc
- Three parameters: genre, sort, and order
- In Express:
req.query.genre
would be “action”req.query.sort
would be “year”req.query.order
would be “desc”
- Query parameter: