Creating the GET /todos route

The first screen you're probably going to show a user is a list of all of their Todos. This is the route you would use to get that information. It's going to be a GET request so I'm going to use app.get to register the route handler, and the URL itself is going to match the URL we have, /todos, because we want to get all of the Todos. Later on when we get an individual Todo, the URL will look something like /todos/123, but for now we're going to match it with the POST URL. Next up, we can add our callback right above app.listen in server.js; this is going to give us our request and response objects:

app.get('/todos', (req, res) => {

});

All we need to do is get all of the Todos in the collection, which we've ...

Get Advanced Node.js Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.