我正在使用sailsjs,我试图用JSON内容类型返回响应。不知道为什么发送后无法设置标题
Application.getEmailDuplicateCheck(options, function(error, result) {
console.log('Email duplicate check error', error);
console.log('Email duplicate check result', result);
if (error) {
return res.serverError(error);
}
if (result) {
return res.ok(result); /*** THIS IS LINE 180 ***/
}
});
而且不知道为什么它总是说“不能设置的标头后,他们被送到”因为我把所有收益的响应;
> Error: Can't set headers after they are sent.
> at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:346:11)
> at ServerResponse.res.setHeader (/home/apps/cat/api/node_modules/express/node_modules/connect/lib/patch.js:134:22)
> at ServerResponse.res.set.res.header (/home/apps/cat/api/node_modules/express/lib/response.js:595:10)
> at ServerResponse.res.send (/home/apps/cat/api/node_modules/express/lib/response.js:151:12)
> at ServerResponse.res.json (/home/apps/cat/api/node_modules/express/lib/response.js:237:15)
> at ServerResponse.res.send (/home/apps/cat/api/node_modules/express/lib/response.js:139:21)
> at /home/apps/cat/api/api/controllers/DuplicateCheckController.js:180:16
嘿,你应该检查这一项,因为它似乎与您的问题http://stackoverflow.com /问题/ 41413776 /时-I-取消注释-1行的代码-I-接收此结果错误-HTTP-出射js359-T/41413857#41413857 – digit