run Promises in parallel


Really simple, but so I remember the syntax

Before

const result1 = await functionOne(params1);
const result2 = await functionTwo(params2);

After

const [ result1, result2 ] = await Promise.all([ functionOne(params1), functionTwo(params2) ]);

source

Date: 2020-07-01

Tags:  javascript

Share: