0
這裏是我的代碼發送:我使用的是貓鼬查詢結果取和響應
hArr = Array();
hash.find({ hash_name: new RegExp('^' + req.body.hash + '$', "i") }, function(err, doc) {
//Do your action here..
if (err) {
res.json({ response: 0, data: "fail", message: " Image Downloadding" });
} else {
for (var h = 0; h < doc.length; h++)
hArr.push(doc[h].img_name);
var unique = hArr.filter(function(elem, index, self) {
return index == self.indexOf(elem);
})
Image.find().where('img').in(unique).exec(function(err, result) {
res.json({ response: 1, data: result, message: "IMage List" });
})
}
});
,當我運行此代碼 它表明
Listening for request
events.js:160
throw er; // Unhandled 'error' event
^
Error: Can't set headers after they are sent.
at ServerResponse.setHeader (_http_outgoing.js:359:11)
at ServerResponse.header (E:\learnNode\insta\node_modules\express\lib\response.js:730:10)
at ServerResponse.send (E:\learnNode\insta\node_modules\express\lib\response.js:170:12)
at ServerResponse.json (E:\learnNode\insta\node_modules\express\lib\response.js:256:15)
at E:\learnNode\insta\routes\api.js:830:25
at E:\learnNode\insta\node_modules\mongoose\lib\query.js:2819:18
at process._tickDomainCallback (internal/process/next_tick.js:129:7)
什麼是文件/行:E:\ learnNode \ insta \ routes \ api.js:830:25? – dpetrini
res.json({response:1,data:result,message:「IMage List」}) – pushpendra