I tried to handle promises with for each but not working
I assume it will log something because of console.log(result)
.
Why is it not working?
It only logs
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
});