I'm not quite sure what's going wrong here. It's supposed to return the body of a given webpage; say: example.com as shown here. When called from a separate program like so:
console.log(aux.requestSomething('example.com'))
the result seen in the console is 'undefined', which is the issue, when it should be returning the body from the page.
var request = require('request');
module.exports = {
requestSomething : function(address){
var x;
var v = address;
request(v, function (error, response, body) { //Grabs data from server
if (!error && response.statusCode == 200) {
x = body;
}
if (error || response.statusCode != 200 ){
console.log('Network Error ' + response.statusCode + '. Program will exit shortly...');
}
return x;
});}}