I have an array of cities. A pretty big array. For every city in the array I need to make 2 requests to my server - 1 request to get the current weather for the city, and another 1 to get today news. For each of those 2 requests there is a special API endpoint. How do I get all the neccessary information properly? I mean:
You can use Promise.allSettled() and then use a timeout to wait for a certain period of time and redo the same. Make sure to use also a request timeout (so when a server is not responding for a long time, you may want to abort).
Here is an example:
const myFunc = async () => {
await Promise.allSettled([ ... ]);
setTimeout(myFunc, 1000);
};