I have the following two files and can't get the result out of my modules request into the var inside app.js.
I thought about module.exports exports as callbacks but I can't find the right combination.
// app.js
#!/usr/bin/env node
// i am a nodejs app
var Myobject = require('./code.js');
var value1 = "http://google.com";
var results = Myobject(value1); // results should stare the results_of_request var value
console.dir(results); // results should stare the results_of_request var value
now comes the module // code.js
// i am a nodejs module
module.exports = function(get_this) {
var request = require('request');
var options = {
url: get_this,
};
request(options, function(error, response, body) {
if (!error) {
// we got no error and request is finished lets set a var
var result_of_function = '{"json":"string"}'
}
}
// the main problem is i have no way to get the result_of_function value inside app.js
}