Created
March 14, 2012 17:08
-
-
Save booyaa/2037937 to your computer and use it in GitHub Desktop.
get body Request and return as string
This file contains hidden or 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'); | |
//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