Skip to content

Instantly share code, notes, and snippets.

@djyde
Created October 4, 2012 08:54
Show Gist options
  • Save djyde/3832329 to your computer and use it in GitHub Desktop.
Save djyde/3832329 to your computer and use it in GitHub Desktop.
APILib
https = require('https');
function API(host){
this.get = function(path,method,callback){
var options = {
host: host,
path: path,
method: method
};
var req = https.request(options,function(res){
res.setEncoding('utf8');
res.on('data',function(row){
callback(row);
});
});
req.end();
}
}
/****
e.g
var github = new API('api.github.com');
github.get('/users/djyde/received_events/public','GET',function(row){
console.log(row)
})
****/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment