我試圖為每個人處理承諾但沒有作業
我認為它會因為console.log(result).
為什么它不起作用?
它只記錄
All done (54) [?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?]
let promises = [];
mkt.forEach(async function (marketItem, index) {
promises.push(() => {
context.program.account.chain
.fetch(sth)
.then((result) => {
console.log(result)
});
});
});
Promise.all(promises)
.then(results => {
console.log('All done', results);
})
.catch(e => {
// Handle errors here
});
uj5u.com熱心網友回復:
你可以試試這個
let promises = mkt.map((marketItem, index) => {
return context.program.account.chain.fetch(sth)
});
Promise.all(promises).then(results => {
console.log('All done', results);
})
.catch(e => {
// Handle errors here
});
不要推動已解決的承諾,推動承諾。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/417645.html
標籤:
上一篇:從React串列中編輯待辦事項
