I promise you this.. parallel async requests with JavaScript promises

Javascript promises are a savvy tool for handling async requests. Promises.all is a method for letting multiple async processes run in parallel before taking off with your data.

Step one: add multiple promises to an array.

Step two: pass the array to Promises.all().

When passed to Promises.all, the method will allow each promise to run concurrently and execute a callback with the .then command when all promises have finished processing.

const promise1 = () => {
return new Promise((resolve, reject) => {
const promiseArray = [promise1, promise2, ...];
Promises.all(promiseArray).then(() => { 
// do stuff here