How to do the equivalent of Promise.all using multiple XMLHTTPRequest?

I need to call multiple HTTP requests and agregate the responses into one record which I’ll dispatch on one last HTTP request.

The requests are:

  • upsert customer info
  • calculate shipping costs

Then bundle those two responses to create a Shopping cart

Normally I would use a Promise.all to be able to run the requests in parallel, but I’m wondering which could be a cancelable/less-colorful way to tackle this scenario.

1 Like

Sure. How are you solving this right now? Got a snippet?

currently I’m using promises.
I am thinking about trying it using some flags, but then I guess I would have to use a setTimeout to check if all the responses have returned. I wonder if there’s a better way. I’ll post a snippet once I have it ready

Sure. I’ll help you with the structuring. I think it’ll be very informative.