Wednesday, 3 May 2017

Delay in each iteration of loop nodejs

I want to wait on every iteration of the loop except the 1st one. This is my code which is working fine for 1st iteration after that setTimeout function wait for some x seconds and run all the iterations at once without wait.

Here is the code

var requests_made = 0;
drivers.forEach(function(driver) {
    if (requests_made == 0) {
        createUser(data);
    } else {
        setTimeout(function () {
            createUser(data);
        },30000);
    }
    requests_made++;
});



via سافٹ ویئر انجینئر

No comments:

Post a Comment