Consider the following scenario:
Inside one of my cron jobs, I'm requesting someone else's service that only allows for 3600 seconds. The API is similar GetPersonForName=string. Think that I have several peoplein my database, and I need to update their information when I can, I go through my database for all people and call this API. Example
People.find({}, function(error, people){
people.forEach(function(person){
var uri = "http://example.com/GetPersonForName=" + person.name
request({
uri : uri
}, function(error, response, body){
sleep(3600)
})
})
})
Not sure if sleep is even ideal, but I need to wait 3600 seconds after every request I make.
source
share