I am working through a great course learning API design with Express.
app.get('/lions/:id', function(req, res){
var lion = _.find(lions, {id: req.params.id});
res.json(lion || {});
});
Anyway I noticed the instructor used lodash for some data manipulations and tried to take a stab at doing the same with the vanilla Array.prototype.filter method
app.get('/lions/:id', function(req, res){
var lion = lions.filter(function(id){
return {id: req.params.id}
});
res.json(lion || {});
});
Any help will be appreciated!
via Antonio Pavicevac-Ortiz
No comments:
Post a Comment