Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
HTTP request helper using Node.js
var http = require('http');
function request(options, callback)
{
http.request(options, function (response) {
var responseBody = '';
response.on('data', function (data) {
responseBody += data;
});
response.on('end', function () {
callback(responseBody);
});
response.on('error', function (e) {
throw e;
});
}).end();
}
exports.request = request;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment