I have the array of promises. I'm using Promise.all
to handle them all. But how can I take the array of values from it? Something like:
const myValueArr = Promise.all(myPromiseArr);
Cannot find respective example.
Thank you in advance
I have the array of promises. I'm using Promise.all
to handle them all. But how can I take the array of values from it? Something like:
const myValueArr = Promise.all(myPromiseArr);
Cannot find respective example.
Thank you in advance
The array of values will be the resolved value of the promise returned by calling Promise.all
.
You get that value as you would the value of any promise resolution:
myValueArr.then( function (array_of_values) {
do_something_with( array_of_values );
});
… or use async
and await
.
You can use the then function to get the values as:
Promise.all(myPromiseArr).then(function(values) {
console.log(values);
});