How to await multiple Promises?

This is correct:

const bar = await Promise.all(promiseArray);

await Promise.all([...]) takes an array of Promises and returns an array of results.

bar will be an array: ['hello', ..., 'hello']

You can also deconstruct the resulting array:

const [bar1, ..., bar10] = await Promise.all(promiseArray);
console.log(bar1); // hello
console.log(bar7); // hello

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)