Skip to content

Instantly share code, notes, and snippets.

@m4munib
Created May 30, 2016 20:28
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save m4munib/4d35ae460f62f8b2eb4d9f2dc412c764 to your computer and use it in GitHub Desktop.
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