originally wrote JAVA, but the sophomore
recently encountered asynchronous programming in the new nodejs, is a bit difficult to understand.
now I am writing a crawler originally done in JAVA, get a url list, submit the request crawl web page with for loop, and then insert several records into the database through for loop after processing.
it seems that the for loop is understood by Synchronize. After the loop is finished, the request asynchronously sends out the request and will not wait, and then the sequelize will not wait.
then finally I want to log a message after all asynchronous processing. These two-level asynchronous operations don"t know how to handle them.
how to wait for all asynchronous operations to finish executing the next command
UPDAT 4Compact 23 1purl 20:
forpromiseAll
4/23 1:41
the question is whether there are more elegant ways that async and await cannot be used in this case, or do I not think of it