Wednesday, April 18, 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

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...