Cannot access value of resolved promise after Promise.all
. As you see in the example below, res.prop
prints undefined. I guess I could create a wrapping function that pushes the resolved value to another responses
array but that does not seem like a clean way to do it.
(async () => {
const responses = []
let counter = 10
while (counter--) {
responses.push(new Promise(resolve => resolve({prop: 10})))
}
await Promise.all(responses)
for (const res of responses) {
console.log(res) // -> prints Promise {prop: 10}
console.log(res.prop) // -> prints undefined
}
})()