我有一个函数,当'dataCompiled‘事件触发时执行,它看起来像他的:
eventEmitter.on('dataCompiled', function () {
json = JSON.stringify({
conversations: convs
});
res.json(json).end();
return;
});但是当我刷新页面时,我得到了错误
Error: Can't set headers after they are sent.发布于 2016-04-04 06:02:27
您确定在此呼叫后不会发送更多数据吗?您不应该使用res.end():http://expressjs.com/en/4x/api.html#res.end。
如果你的代码中有另一个地方,你正在向res发送更多的数据,它会给出你正在接收的错误消息,res.end没有修复潜在的问题。
https://stackoverflow.com/questions/36391578
复制相似问题