As I pondered the task at hand, I realized that using a sleep function might be beneficial. However, Javascript lacks a built-in sleep function.
How can I tweak this process to avoid hitting a Parse rate-limit? My goal is to execute one (1) Parse.Cloud.run
method every 5 seconds.
$('.website').each(function(i) {
var website = $(this).text();
Parse.Cloud.run('getMainEmail', {url: website}, {
success: function(result) {
cell.next().text(result);
},
error: function(error) {
console.log("Couldn't find email for website: " + website);
console.log(error);
}
});
});
Currently, the code scans all websites in the DOM and triggers numerous Parse requests simultaneously - resulting in an immediate rate limit restriction.