Created
July 27, 2016 15:02
-
-
Save Cartman720/a559c7f77fe007865cb6773cef783b01 to your computer and use it in GitHub Desktop.
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
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