I'm developing a web scraper (in its early stages) and I plan to do x horseman calls. This calls are promise based but I want the calls to be sequentially, when one finishes, the next starts.
How can I achieve this behavior?
I'm developing a web scraper (in its early stages) and I plan to do x horseman calls. This calls are promise based but I want the calls to be sequentially, when one finishes, the next starts.
How can I achieve this behavior?
Copyright © 2021 Jogjafile Inc.
You can simply do something like:
Here
asyncCallis whatever function you need to call. It takes some arguments and returns aPromise.So you are basically waiting for the result of one call and then invoking the second call.
However, this can get pretty unwieldy when there's a lot of calls to make. If you are using
async/await, which you should, given that you're working on a new project, you can code it much better like:Or, even better: