In JavaScript, promise.all() returns a single promise given an iterable of promises. The returned promise is fulfilled when all the iterable promises are fulfilled. If one promise is rejected, the resulting promise is also rejected.
1
2
3
4
5
6
try{constvalues=awaitPromise.all([promise1,promise2]);console.log(values);// [resolvedValue1, resolvedValue2]
}catch(err){console.log(error);// rejectReason of any first rejected promise
}
How to use promise.all() in Python
Python natively supports similar functionality to promise.all(). The method is named asyncio.gather().