我對node.js仍然很陌生,這裏的數組包含一個id列表。當我把從foreach循環的反應,我越來越Error: Can't set headers after they are sent.
我GOOGLE了它,但不能正確理解錯誤:從forEach循環發送後無法設置標頭
array.forEach(function(data) {
db.collection.find({
_id: mongoskin.helper.toObjectID(data)
}).toArray(function(err, data1) {
if (err) return next(err);
console.log(data1);
res.send(data1);
})
})
檢查出這個http://stackoverflow.com/questions/7042340/node-js-error-cant-set-headers-after-they-are-sent – vineet