Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Building a MEAN Application Going MEAN with Angular GET-ing TODOs

Craig Heslop
Craig Heslop
22,474 Points

How would I create an individual get route as opposed to returning all todos?

The get route retrieves all results, how would I go about being able to retrieve a singular result route, using the id of the todo etc, for the purposes of viewing more information for example?

1 Answer

akak
akak
29,445 Points

To get a todo by passing an id in the url

app.get('/todos/:id', function (req, res) {
    var id = req.params.id;

        Todos.findById(id, function(err, data) {
            // do whatever you want with the single todo
        });
});