Q: Get query results from Sequelize then run a scraper job result by result I am trying to query a DB through Sequilize, then I would like to use each record returned to run a Scraping job (using puppeteer). I would like it to run only record by record, like we start scraping the first record, then wait the first one to finish then move on to the second record.
Here is my code so far
Scraping controller:
exports.directFind = async (vin, res) => {
    if (vin) {
        let browserInstance = browserObject.startBrowser();
        await scraperController(browserInstance,vin)
        .then(results => {
            return res(results)
        });
    } 
};

Function to send notification with the scraper
const sendNotif = async () => {
    Vins.findAll({raw : true}).then(async (vins) => {
        await vins.map(async (vin) => {
            console.log(vin.vin)
            await search.directFind(vin.vin,function(res) {
                status.findLatestVinStatus(vin.id,function(latestVINStatus) {
                    if (latestVINStatus.vmacs3CharCode == res.result.order.vmacs3CharCode || latestVINStatus.gobStatusCode == res.result.order.gobStatusCode) { //to be cganged for prod
                        console.log("we need to send notif")
                        //sendEmail(res.result)
                    }
                });
            })
            console.log('end')
        });
    })
}

Thanks

A: You can use a for loop to go over the results one by one:
for (const vin of await Vins.findAll({raw : true})) {
  await search.directFind(vin.vin, res => { // ... })
}

