Skip to content

Instantly share code, notes, and snippets.

@booyaa
Created March 14, 2012 17:08
Show Gist options
  • Save booyaa/2037937 to your computer and use it in GitHub Desktop.
Save booyaa/2037937 to your computer and use it in GitHub Desktop.
get body Request and return as string
var Request = require('request');
//doesn't work var Numbers = Numbers || {};
var Numbers = function() {
// constructor
}
Numbers.prototype = {
baseUrl : 'http://numbersapi.com/'
, math: function(integer) {
console.log('DEBUG: ' + this.baseUrl + integer.toString() + "/math");
Request(this.baseUrl + integer.toString() + "/math", function(err,res,body) {
console.log('BODY: ' + body);
// how do I return body after the callback?
});
return body (from Request call)
}
};
exports.Numbers = Numbers;
exports.createNumbers = function() {
return new Numbers();
}
exports.version = '0.0.1';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment