我有這樣的代碼,'for'沒有執行。nodejs塊,直到'for'迭代完成
var obj = [];
for (var i = 0, len = param.destinations.length; i < len; i++) {
var params = {
origins: param.origins,
destinations: param.destinations[i]
}
test(params, function(err, response) {
console.log(response);
return obj.push(response);
})
}
console.log(obj);
return callback(null, obj);
如何解決
if'param.destinations.length' == 0,你永遠不會爲 – Fefux
做param.destinations有長度嗎? – yBrodsky
什麼是錯誤? –