Getting an individual resource – GET /todos/:id

In this section, you are going to create an API route for fetching an individual Todo. Now, most of this section is going to be a challenge but there is one thing I want to show you before we get started, and that is how to fetch a variable that's passed in via the URL. Now, as I mentioned, the structure for this URL is going to be a GET request, /todos, then we're going to dive into the Todos, fetching an individual item where the ID gets passed, such as /todos/12345. This means that we need to make the ID part of the URL dynamic. I want to be able to fetch that value, whatever a user happens to pass in, and use it to make the query. The query that we set up in the mongoose-queries file like ...

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.