challenges: 404 challenge not foudn on GET /challenge/:cid

This commit is contained in:
Tyler Renelle
2013-11-01 00:30:39 -07:00
parent 751ae60342
commit cc5126f09b

View File

@@ -98,6 +98,7 @@ api.get = function(req, res) {
.populate('members', 'profile.name habits dailys rewards todos')
.exec(function(err, challenge){
if(err) return res.json(500, {err:err});
if (!challenge) return res.json(404, {err: 'Challenge ' + req.params.cid + ' not found'});
// slim down the return members' tasks to only the ones in the challenge
_.each(challenge.members, function(member){
if (member._id == user._id)