0
0
Expressframework~5 mins

GET route handling in Express - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
Aapp.get()
Bapp.post()
Capp.put()
Dapp.delete()
In Express, what does the res.send() method do inside a GET route?
ASends a response back to the client
BReceives data from the client
CStarts the server
DDefines a new route
What object holds information about the client's request in a GET route handler?
Ares
Bserver
Capp
Dreq
How do you send JSON data in response to a GET request?
Ares.sendFile()
Bres.json()
Cres.redirect()
Dres.render()
Which URL path will this route handle? app.get('/about', ...)
A/
B/home
C/about
D/contact
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.