2014-04-23 35 views
0

在我的node.js應用程序上,如果在mongo查詢上發生錯誤,我使用res.end。但是代碼會繼續執行,並且應該在res.end之後放置一個返回值嗎?我應該使用返回mongo錯誤

book.find({key:'123'},function(err){ 
    if(err) res.end(); 
    console.log("lots of blah blah"); 
}); 

回答

0

要停止「等等」,您應該return res.end();

喜歡的東西:

book.find({key:'123'},function(err){ 
    if(err) return res.end(); 
    console.log("lots of blah blah"); 
}); 
相關問題