I find that I cannot get the response when using promise.all
.
The orders
below should be an array
Promise.all(promises).then(function (orders) {
console.log(orders); // nothing logged
});
Full code
let promises = markets.map(async (mkt) => {
return new Promise(async function (resolve, reject) {
return functionA(paramA)
.then(resA => {
return res.functionB()
.then((resB) => {
if (resB.length > 0) {
return functionC()
.then(resC => {
console.log(resC); // successfully logged
return resC;
});
}
});
})
.catch(err => console.log(err));
});
});
Promise.all(promises).then(function (orders) {
console.log(orders); // nothing logged
});
How can I fix?