Skip to content

Instantly share code, notes, and snippets.

@mewm
Created May 17, 2014 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mewm/e5c7faa61646db1f0020 to your computer and use it in GitHub Desktop.
Save mewm/e5c7faa61646db1f0020 to your computer and use it in GitHub Desktop.
Syncrounous loop in javascript without dependencies
var page = 2;
var last_page = 100;
(function loop() {
if (page <= last_page) {
request("/data?page=" + page, function (error, response, body) {
if (!error && response.statusCode == 200) {
store_data(body)
}
page++;
loop();
});
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment