Skip to content

Instantly share code, notes, and snippets.

@Cartman720
Created July 27, 2016 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cartman720/a559c7f77fe007865cb6773cef783b01 to your computer and use it in GitHub Desktop.
Save Cartman720/a559c7f77fe007865cb6773cef783b01 to your computer and use it in GitHub Desktop.
var request = require("request"),
querystring = require("querystring");
module.exports = function(){
this.get = function (options,callback){
var Options = function(options){
this.method = "GET";
if (options.key !== undefined) {
this.headers = {
"SessionKey":options.key
}
};
if (options.data !== undefined) {
this.url = options.url+"?"+querystring.stringify(options.data);
}
else{
this.url = options.url;
}
}
var options = new Options(options);
var result;
request(options,callback)
}
this.post = function (options,callback){
var Options = function(options){
this.method = "POST";
this.url = options.url;
if (options.key !== undefined) {
this.headers = {"SessionKey":options.key}
};
if (options.data !== undefined) {
this.json = options.data
}
}
var options = new Options(options);
var result;
request(options,callback)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment