-
GET request includes query parameters after the
?symbol. Example:http://locahost:4000/forest?daylight=true- URL query parameters are automatically parsed by Express and are defined in the
request.queryobject.
- URL query parameters are automatically parsed by Express and are defined in the
-
Create a route handler for an endpoint of your choice:
app.get('/forest', (request, response) => { response.send("You are in a deep, dark wood..."); })
-
Add a conditional message based on a URL query parameter:
app.get('/forest', (request, response) => { let daylight = request.query.daylight; if (daylight === 'true') { response.send("You are in a deep, decently lit wood..."); } else { response.send("You are in a deep, dark wood..."); } })