can nodejs return request module data as a global change
related codes
var request = require("request");
var URL = require("url");
var iconv = require("iconv-lite");
var url = "https://segmentfault.com/q/1010000010487842/";
request({
encoding: null,
url: url
}, function (error, response, body) {
var array1 = /<title>(.*)<\/title>/gi.exec(body);
if (array1 != null) {
var title = array1[1];
//console.log(title);
}
console.log(title);
return title;//
});
//console.log(title);//titletitle is not defined
//
whether title can be returned as a global variable.