Recall & Review
beginner
What is a GET route in Express?
A GET route in Express is a way to handle HTTP GET requests from clients. It defines what the server should do when a user visits a specific URL.
Click to reveal answer
beginner
How do you define a GET route for the path '/home' in Express?
You use
app.get('/home', (req, res) => { res.send('Hello Home'); }); to define a GET route that sends 'Hello Home' when '/home' is visited.Click to reveal answer
beginner
What do the
req and res objects represent in a GET route handler?req is the request object containing information from the client, like query data. res is the response object used to send data back to the client.Click to reveal answer
intermediate
How can you send JSON data in response to a GET request in Express?
Use
res.json({ key: 'value' }) inside the GET route handler to send JSON data back to the client.Click to reveal answer
beginner
Why is it important to handle GET routes properly in a web server?
Proper GET route handling ensures users get the right content when they visit URLs. It helps the server respond quickly and correctly, improving user experience.
Click to reveal answer
Which method defines a GET route in Express?
✗ Incorrect
The app.get() method is used to define a GET route in Express.
In Express, what does the
res.send() method do inside a GET route?✗ Incorrect
res.send() sends a response back to the client.What object holds information about the client's request in a GET route handler?
✗ Incorrect
The
req object contains information about the client's request.How do you send JSON data in response to a GET request?
✗ Incorrect
Use
res.json() to send JSON data in response.Which URL path will this route handle?
app.get('/about', ...)✗ Incorrect
The route handles GET requests to the '/about' path.
Explain how to create a simple GET route in Express that returns a welcome message.
Think about how you tell the server what to do when someone visits a URL.
You got /4 concepts.
Describe the roles of the
req and res objects in a GET route handler.One listens to the client, the other talks back.
You got /3 concepts.