I have the following code that the data is returning right by console.log()
var request = require("request");
var myJSON = require("JSON");
function resultado(url, callback) {
request({
url: url,
json: true
}, function(error, response, body) {
callback(null, body);
});
}
module.exports.cfg = resultado('http://localhost/conf/site', function(err, body) {
console.log(body)
return body
});
When I do not require this file in another
var conf = require('./config/config')
console.log(conf.cfg);
It returns undefined
Anyone there could help me how to recover these values is can they use them? equal returns no console.log(body)
?
or is there any package that already does this?