I met a problem recently: How can i assign value to a global variable?
when i try to return a, i found that is undefined, and the "value" i wanna to assign to it is not undefined.
my code is like this:
module.exports = function (jsonStr) {
var a;
request(main_url, function(error, response, html) {
if(!error) {
...
request(sub_url, function(error, response, html) {
if(!error) {
...
a = value;
...
}
}
}
}
return a;
});