你好,在vscode里扩展.js我不能在变量“chunk”所在的函数之外使用它:
let http = require('http');
let keyname = "key.key";
http.get('http://mysite.nl/vscode/?with=data', function(res) {
res.on("data", function(chunk) {
vscode.window.showInformationMessage("INSIDE: " + chunk);
});
});
vscode.window.showInformationMessage("OUSIDE FUNCTION:" + chunk); /*this does not work*/
let globalvar;
let http = require('http');
let keyname = "key.key";
http.get('http://mysite.nl/vscode/?with=data', function(res) {
res.on("data", function(chunk) {
vscode.window.showInformationMessage("INSIDE: " + chunk);
globalvar = chunk;
});
});
vscode.window.showInformationMessage("OUSIDE FUNCTION:" + globalvar); /*this does not work*/