Wednesday, 18 April 2018

javascript - Async wait for a function

I'm trying to send an SMS for a function. But the problem is: The function takes about 10-15 seconds to finish (Since we do bunch of stuff with PhantomJS).



_.each(users, function(userData){ // This does not work since i need to wait for 15 seconds
smsFree.sendSMSFree(userData, productUrl);
});


I've even tried using setTimeout but that didn't quite work as well.




I'm on NodeJS. How can I leverage Async or some other library to solve my problem?



I want to wait for 15 seconds then loop to the second object. Not sure how this is achieved. (Async.serial?)

No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...