Recall & Review
beginner
What is
req.query in Express?req.query is an object in Express that holds the query string parameters sent in the URL of a GET request.
Click to reveal answer
beginner
How do you access a query parameter named
name in Express?You use req.query.name to get the value of the name parameter from the URL query string.
Click to reveal answer
beginner
Example URL:
/search?term=books&sort=asc. How does req.query look?req.query will be an object: { term: 'books', sort: 'asc' }.
Click to reveal answer
beginner
What type of data does
req.query contain?req.query contains all query parameters as strings inside an object. Even numbers or booleans come as strings.
Click to reveal answer
intermediate
Can
req.query handle multiple values for the same key?Yes, if the URL has repeated keys like ?tag=js&tag=node, req.query.tag will be an array: ['js', 'node'].
Click to reveal answer
What does
req.query represent in Express?✗ Incorrect
req.query holds the query string parameters from the URL, like ?key=value.
How do you access the value of
?page=3 in Express?✗ Incorrect
Query parameters are accessed via req.query.
If the URL is
/items?color=red&color=blue, what is req.query.color?✗ Incorrect
Repeated query keys become arrays in req.query.
What data type are values inside
req.query?✗ Incorrect
All query values come as strings by default.
Which HTTP method usually sends data accessible via
req.query?✗ Incorrect
Query strings are mostly used with GET requests.
Explain how
req.query works in Express and how you use it to get query string values.Think about how URLs have ?key=value and how Express reads that.
You got /5 concepts.
Describe a real-life example where you might use
req.query in a web app.Imagine a shopping site where you filter products by category or price.
You got /4 concepts.