DEVELOPER LEVEL -
I've recently started to code. I'm working on this NodeJs Automation program, that uses Puppeteer.
THE PROJECT -
1.) I have a list of URLs from a Video-Platform WebSite.
> The Script goes to these URLs
> Saves the Data like Title, Tags, Actors etc
> Downloads the Video, Saves it locally.
.. >>Though this above 'Workflow' that I've given isn't important, but I still include it, don't know might help.
THE PROBLEM -
I'm using the for
loop to go through each URL, and call my async
function for the above ↑ work.
There is no problem with my async
function - that gets all the data.
BUT the problem is - It doesn't wait to finish before moving to the next item in the loop.
If I set the for Loop's
range to suppose 10 , then 10 async
Functions start Together.
How do I set this code in a way, that my async
functions run 1-by-1, along with the Loop.
CODE -
for (i = 0; i <= 10 + 1; i++) {
(async () => {
await automator(`${savedArray[i]}`).then(() => console.log("automator complete"))
})()
}
How do I change it so it waits for completion, before starting again, When I use it in another `async` Functions, like ↑ above. I wuld be really grateful if you can help me in this one. – Anupma Mar 23 '21 at 13:54