1
Promise.all(function(){
for(var numb in req.body)
{
console.log(numb+":"+req.body[numb]);
checkValue(numb,function(err,result){
if(result)
{
console.log(result);
send[result]="true";
console.log(send);
}
if(err)
{console.log(err+"not");}
});
}
}).then(res.json(send));
我想首先執行for循環,然後發回數據。我正在嘗試使用promise.all,但我不確定它是否正確。有人能幫助我嗎?承諾在node.js循環
請格式化/縮進你的代碼正確,使其可讀。 – jfriend00
您將一組承諾傳遞給'Promise.all()'。您不會將函數傳遞給'Promise.all()'。你所顯示的代碼中也沒有異步操作,所以根本沒有理由使用promise。你可以編寫一個規則的循環。 – jfriend00