Recall & Review
beginner
What is a query string in a URL?
A query string is the part of a URL after the question mark (?) that contains key-value pairs used to send data to the server.
Click to reveal answer
beginner
How does Express.js parse query strings by default?
Express.js automatically parses query strings into an object accessible via
req.query in route handlers.Click to reveal answer
beginner
Example: What does
req.query contain for URL /search?term=books&sort=asc?{ term: 'books', sort: 'asc' } - an object with keys and values from the query string.Click to reveal answer
beginner
How can you access a specific query parameter in Express?
Use
req.query.parameterName. For example, req.query.term gets the value of the 'term' parameter.Click to reveal answer
beginner
What happens if a query parameter is missing in the URL?
The corresponding key in
req.query will be undefined or not present, so you should check before using it.Click to reveal answer
In Express.js, where do you find parsed query string parameters?
✗ Incorrect
Express parses query strings into the req.query object.
What symbol starts the query string in a URL?
✗ Incorrect
The question mark (?) marks the start of the query string.
If the URL is '/items?category=books&price=low', what is req.query.price?
✗ Incorrect
The price parameter has the value 'low'.
What type of data is req.query in Express?
✗ Incorrect
req.query is an object containing key-value pairs from the query string.
If a query parameter is missing, what does req.query.parameter return?
✗ Incorrect
Missing parameters return undefined in req.query.
Explain how Express.js handles query string parsing and how you access query parameters in a route.
Think about how URLs send extra data and how Express makes it easy to read.
You got /4 concepts.
Describe what happens if a query parameter is not included in the URL and how your Express code should handle it.
Consider what happens when you ask for something that isn't there.
You got /3 concepts.