something like this:
var aaa = 0;
http.get (" http://abc.com/api"", function (res) {
var json = "";
res.on("data", function (d) {
json += d;
});
res.on("end",function(){
//
json = JSON.parse(json);
aaa = json;
});
}). On ("error", function (e) {
console.error(e);
});
console.log (aaa);
because of the problem of returning data asynchronously, aaa actually does not get the data of json, and the output is still zero; how to make the output of aaa to the value of json?