Reputation: 393
My server returns an empty object if it gets to the last condition, where code is 204:
exports.get_group_profile = function(req, res) {
Work.findById(req.params.work_id, function(err, work) {
if (err || !work)
return res.send(404);
if (work.admin.id === req.user._id){
console.log('here');
return res.json(200, work.profile);
}
if (work.users.indexOf(req.user._id)> -1)
return res.json(201, work.profile);
if (work.invited.indexOf(req.user._id) > -1)
return res.json(202, work.profile);
for (var i=0;i<work.appliers.length;i++) {
if (work.appliers[i].id == req.user._id)
return res.json(203, work.profile);
}
if (work.visibility!=0){
console.log(work.profile);
return res.json(204, work.profile);
}
return res.send(404);
});
};
Any condition but this one returns work.profile (which is a virtual in mongoDB) properly. The log before the return prints the object I need but I have no trace of it on my client side. Any idea ?
Upvotes: 2
Views: 53
Reputation: 1839
From this website: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.5
The 204 response MUST NOT include a message-body, and thus is always terminated by the first empty line after the header fields.
This is why you are not seeing anything on the client side.
Upvotes: 3