var request = require("request");
var path = "xxx.json";
getBody : function(callback, path) {
var self = this;
var options = {
method : "GET",
uri: path,
headers: {
'authorization-type': 'application/json',
'Connection': 'keep-alive',
'Accept': '*/*',
},
json: true,
};
request.get(options, function(error, response, body){
self.key = body.key;
console.log(self.key);
});
console.log(self.key);
}
The second console.log give always an undefined, How can I read the content of body when I'm out of the request.get? And I've tried with fucntion callback and also global variable, none of them works, thanks in advance for yours suggestions.