我在Node.js的一個對象數組和謹RESPONSE.WRITE();它在屏幕上,我可以設法得到的第一個對象了,但循環停止,只有第一輸出,任何人可以點我在正確的方向...迭代對象爲HTTP響應
db.collection('todo', function(err, collection){
collection.find(function(err, cursor) {
cursor.each(function(err, doc) {
for(docs in doc){
if(docs == "_id"){
}else{
var test = docs + " : " + doc[docs];
}
}
data = data.toString("utf8").replace("{{TEST}}", test);
response.write(data);
response.end();
})
});
});
不久,當您調用response.end時,即完成響應。你的意思是調用response.write嗎? – Joe