Skip to content
Advertisement

JS async / await tasks queue

In my JS app I’m using the async / await feature. I would like to perform multiple API calls and would like them to be fired one after other. In other words I would like to replace this simple method:

JavaScript

with something more complex.. like:

JavaScript

What will be the best way to handle the asynchronous returns?

Advertisement

Answer

You could save previous pending promise, await for it before calling next fetch.

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement