Skip to content

Instantly share code, notes, and snippets.

@RamadhanAmizudin
Created February 10, 2014 08:15
Show Gist options
  • Save RamadhanAmizudin/8912160 to your computer and use it in GitHub Desktop.
Save RamadhanAmizudin/8912160 to your computer and use it in GitHub Desktop.
Node.JS / Request
var request = require('request');
var hosts = ["http://host1/", "http://host2/", "http://host3/"];
hosts.forEach(function(val) {
request.get(val + 'status', function(error, response, body) {
var r = JSON.parse(body);
var status = r.status;
});
});
// How can I do if status == 'idle' and immedietly break the loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment