Files
main.tsmain
What you'll learn
- Create an app with express(), add routes with app.get(), and start it with app.listen()
- Read path parameters from req.params and the query string from req.query
- Answer with res.json() and res.send(), set the status with res.status() and the content type with res.type()
Press Run tests to start the app. Its log appears here.Graded endpoints
The starter's route: res.send() with a string, which Express answers as HTML
res.json() serialises the array and says so in the content type
req.query.minAge is the string "4"; only Luna is that old
req.params.id is "2", a string, compared as a number
res.status(404) before res.json(): the status line changes, the body explains
A string is HTML to res.send() unless res.type() says otherwise
The same 404, from the second route