Skip to content

Instantly share code, notes, and snippets.

@m4munib
Created May 30, 2016 21:53
  • 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/6abf1863407c8b2907af1bfe1d0777e9 to your computer and use it in GitHub Desktop.
GET/POST HTTP request Node.js
/*GET Request*/
var httpHelper = require('./helper/http');
var options = {
host: 'www.domain.com',
path: '/example-page',
method: 'GET'
};
httpHelper.request(options, function (body) {
console.log(body);
});
/*Post Request*/
var httpHelper = require('./helper/http');
var options = {
host: 'www.domain.com',
path: '/example-page',
method: 'POST'
};
httpHelper.request(options, function (body) {
console.log(body);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment