Question: I need to wait for two `fetch()` API calls and then to save data from each fetch to different window object. I found this article <https://gomakethings.com/waiting-for-multiple-all-api-responses-to-complete-with-the-vanilla-js-promise.all-method/> and tried following code to wait for the API calls:

```
Promise.all([
    fetch('https://jsonplaceholder.typicode.com/todos/1'),
    fetch('https://jsonplaceholder.typicode.com/todos/2')
]).then(function (responses) {
    // Get a JSON object from each of the responses
    return Promise.all(responses.map(function (response) {
        return response.json();
    }));
}).then(function (data) {
    // Log the data to the console
    // You would do something with both sets of data here
    console.log(data);
}).catch(function (error) {
    // if there's an error, log it
    console.log(error);
});

```

However when pasting this in browser console, the result is not being logged.

**What is wrong with the code and how to wait for both to be resolved?**

Answer: 
```js
const fetchData = async () => {
  try {
    const responsesJSON = await Promise.all([
        fetch('https://jsonplaceholder.typicode.com/todos/1'),
        fetch('https://jsonplaceholder.typicode.com/todos/2')
    ]);
    const [todoOne, todoTwo] = await Promise.all(responsesJSON.map(r => r.json()));
    console.log(todoOne, 'todoOne');
    console.log(todoTwo, 'todoTwo');
  } catch (err) {
    throw err;
  }
};

fetchData();
```

Might be looking for something like this.
please use axios for fetch data in js . react or angular etc...

<https://github.com/axios/axios>
please install with npm and read doc

```
$ npm install axios

```

```
axios.get('/user')
  .then(function (response) {
    console.log(response);
    axios.get('/user')  .then(function (res) {
     console.log(res);
    })
  })

```

when first req is finish,
then start req sec