2
I have the following code that the data are 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 require in that file in another
var conf = require('./config/config')
console.log(conf.cfg);
he returns Undefined
someone ai could help me how to recover these values is can use them ? equals returns in console.log(body)
?
or if there is any package that already does that ?