JavaScript - Promise.all getting response

less than 1 minute read

Promise.all guarantee the order of response in input promises so that caller can retrieve the result with array index number.

1
2
3
4
5
6
7
8
var allDone = Promise.all([
    promise1,
    promise2
])
.then(res => {
    res[0]; // promise1 result
    res[1]; // promise2 result
});