Asynchronous operations in node loops

async en_exec_list ()
    {
        
        console.log("************************************************")
        
        //   //ID
          var sql = "SELECT * FROM en_del_products WHERE  STATE = 0 limit 1";
          var waitList = await mysql_auto_db.await_query(sql);
        
          for( let doc of waitList)
          {
              let c= await ftp_db.await_query({
                action: "delete",
                offlinePath: "www/1.txt"
            });
            console.log(c)
          }

          console.log("************************************************")

    }

Hello, what can I do to wait for the end of the for execution before the end of the print run?

ftp_db.await_query is self-encapsulated and used to delete files in FTP.

current error message:

clipboard.png

Mar.02,2022

error report means that ftp_db.await_query executes an error but you don't catch it. The asynchronous order of the code you write should be fine


every promise in the loop is placed in an array, and the promise.all.then ends at the end of the print run


The methods of

await are all placed under Promise.all, and then the print run ends in the callback then.

because await is executed asynchronously in your code, console, will be executed first and then the methods that follow await will be executed.

at the same time, because there is no relationship between them, whoever returns first ends first.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3e3ff-2c3f0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3e3ff-2c3f0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?