I have a very special scenario where I have n
number of object arrays. Then, I need to make n
number of API calls. Currently, I'm using Promise.all as shown in code sample below.
const requests = [];
for (let i = 0; i < cache.length; i++) {
requests.push(request.handleCache(cache[i]));
}
await Promise.all(requests);
As I understand, Promise.all
will dispatch all requests concurrently, which means server will receive the requests in any order, right. But I need to receive the requests from server in the order as it is in cache
because I have to handle the requests in the same order on my server.
How can I send the requests one after another sequentially?