未返回非空对象-Node.js

未返回非空对象-Node.js,node.js,Node.js,如果达到最后一个条件,我的服务器将返回一个空对象,其中代码为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.

如果达到最后一个条件,我的服务器将返回一个空对象,其中代码为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);
});
exports.get\u group\u profile=函数(请求、恢复){
Work.findById(req.params.Work\u id,函数(err,Work){
如果(错误!工作)
返回res.send(404);
if(work.admin.id==req.user.\u id){
console.log('here');
return res.json(200,work.profile);
}
if(work.users.indexOf(req.user.\u id)>-1)
return res.json(201,work.profile);
if(工作邀请索引(请求用户id)>-1)
return res.json(202,work.profile);
对于(var i=0;i来自本网站:

204响应不能包括消息体,因此总是由头字段后的第一个空行终止


这就是为什么您在客户端看不到任何东西。

您让我意识到响应比与我的客户端交谈更有意义!您知道Express中处理此行为的方式吗?感谢您提供的链接!我猜,由于它是在某些RFC中编写的,Express应该忽略第二个参数。