Multiple API fetches without async function() and Promise.all()
02:39 03 Jun 2026

Is it possible to run multiple API calls without using an async() function and Promise.all()? I'm writing a little webapp where I need to fetch data from different APIs, but eventually each will automatically be updated (i.e. the API called again) at different time intervals.

I'm using setInterval() for the refresh and due to the different intervals, was trying to wrap each separate API call in its own function. However, that doesn't seem to work. When I ignore the automatic update for a second, I am able to have all API calls work as an async function() with Promise.all(), however, that's not what I need.

The problem seems to specifically stem from using the same api key twice. A third API call using a different apiKey and a different url works (i.e. I then see data1 and data3 and get those refreshed at different intervals, but still no data 2).

Why does the code work for two different API keys, but not when using the same one? Is the async Promise.all approach actually the recommended method?

const apiKey = ... ;
const url1 = `https://api.api1...&key=${apiKey};
const url2 = `https://api.api2...&key=${apiKey};

This works (but can't have different update intervals):

async function fetchData() {
  try {
    const [response1, response2] = await Promise.all([
      fetch(url1),
      fetch(url2)
    ]);

    const data1 = await response1.json();
    const data2 = await response2.json();

    [ ... do something with data1 and data 2... ]

    }catch (error) {
        console.error('One of the APIs failed:', error);
    }
}

This doesn't work (only shows and updates data1):

function get_data1() {
    fetch(url1)
      .then(response => response.json())
      .then(data1 => {
         [... do something with the data ... ]
      })
}

function get_data2() {
    fetch(url2)
      .then(response => response.json())
      .then(data2 => {
         [... do something with the data ... ]
      })
}

//initialize data
get_data1();
get_data2();


//update data at different intervals (e.g. 1min, 2min)
setInterval(get_data1, 60000);
setInterval(get_data2, 120000);
javascript