Skip to content

Commit

Permalink
Added route to get ids of favorite heroes.
Browse files Browse the repository at this point in the history
  • Loading branch information
GustavoDinizMonteiro committed May 9, 2017
1 parent cafb542 commit 3682ebf
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/routes/hero_routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,21 @@ module.exports = function(app) {
if(index >= 0) {
doc.favorites.splice(index, 1);
}

doc.save();
return res.status(200).json({ success: true, message: 'Successfully unmarked hero as favorite'});
});
});


apiRoutes.get('/favorite', passport.authenticate('jwt', { session: false }), function(req, res) {
User.findOne({email: req.user.email}, function(err, doc) {
if (err) throw err;

return res.status(200).json({ success: true, message: 'Successfully unmarked hero as favorite', favorites: doc.favorites});
});
});

// Set url for API group routes
app.use('/api/heroes', apiRoutes);
};

0 comments on commit 3682ebf

Please sign in to comment.