Handling multiple async operations in Javascript with Promise.all()
Words
82
Reading
1 min
Listen
Play
9y
Here is a simple javascript promise operation that demonstrates the handling of multiple async operations with the Promise.all() method.
In the code, I am only showing the resolved results, but you can add a condition to reject the promise and see what happens:
You can see I had created two functions to add and subtract numbers. The add is called after 100ms and the sub is called after 1200ms. But we get our response after both have been resolved.
Hope this helps!