Complete the code to create a GET route for the path '/hello'.
app.[1]('/hello', (req, res) => { res.send('Hello World!'); });
The get method defines a route that responds to GET requests.
Complete the code to send a JSON response with a message in the GET route.
app.get('/json', (req, res) => { res.[1]({ message: 'Hello JSON' }); });
sendFile which sends a file, not JSON.render which is for templates.The json method sends a JSON response to the client.
Fix the error in the GET route that tries to access a URL parameter.
app.get('/user/:id', (req, res) => { const userId = req.params.[1]; res.send(`User ID is ${userId}`); });
req.param instead of req.params.The URL parameter is named 'id', so access it with req.params.id.
Fill both blanks to create a GET route that sends a status code and a JSON message.
app.[1]('/status', (req, res) => { res.status([2]).json({ message: 'All good' }); });
Use get for GET route and 200 for successful status code.
Fill all three blanks to create a GET route that reads a query parameter and sends it back in JSON.
app.[1]('/search', (req, res) => { const term = req.query.[2]; res.[3]({ searchTerm: term }); });
params instead of query for query parameters.send instead of json for JSON response.The route uses get, reads query parameter query, and sends JSON response.
