Created
October 4, 2012 08:54
-
-
Save djyde/3832329 to your computer and use it in GitHub Desktop.
APILib
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
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