Created
December 17, 2011 22:07
-
-
Save ryanrolds/1491554 to your computer and use it in GitHub Desktop.
svnlto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function request(callback) { | |
var http, options; | |
http = require("http"); | |
options = { | |
host: "api.outofme.de", | |
port: 80, | |
path: "/graphics", | |
method: "GET" | |
}; | |
http.get(options, function(res) { | |
var data = ""; | |
res.on("data", function(chunk) { | |
return data += chunk; | |
}); | |
res.on("end", function() { | |
callback(null, data); | |
}); | |
}).on('error', function(error) { | |
callback(error); | |
}); | |
} | |
//Usage | |
request(function(error, body) { | |
console.log(body); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment