# How to wait for 2 or more promises to resolve in JavaScript

> Learn how to wait for two or more promises to resolve in JavaScript with Promise.all(), reading the results from the returned array, using await or then().

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2019-10-25 | Topics: [JavaScript](https://flaviocopes.com/tags/js/) | Canonical: https://flaviocopes.com/how-to-wait-multiple-promises-javascript/

Say you need to fire up 2 or more [promises](https://flaviocopes.com/javascript-promises/) and wait for their result.

And you want to go on, once you have both resolved.

How can you do so, in [JavaScript](https://flaviocopes.com/javascript/)?

You use `Promise.all()`:

```js
const promise1 = //...
const promise2 = //...

const data = await Promise.all([promise1, promise2])

const dataFromPromise1 = data[0]
const dataFromPromise2 = data[1]
```

You can see how `Promise.all()` compares to `allSettled()`, `race()` and `any()` in the [promise combinators tool](https://flaviocopes.com/tools/promise-combinators/).

If you prefer using pure promises and not [async/await](https://flaviocopes.com/javascript-async-await/), use this syntax:

```js
const promise1 = //...
const promise2 = //...

Promise.all([promise1, promise2]).then(data => {
	const dataFromPromise1 = data[0]
	const dataFromPromise2 = data[1]
})
```
