1
我正在使用我的第一个节点模块,并且在函数中使用变量时遇到了一些问题。第一个控制台日志给了我我的数据,但第二个控制台日志给我未定义。nodejs全局变量不能按预期工作
module.exports = {
getClient: function() {
var options_auth={user: username, password: password};
return new Client(options_auth);
},
getTestCaseById: function(client, args, testCaseId) {
var restResponse;
url = baseurl + "testcase/" +testCaseId;
client.get(baseurl + "testcase/" +testCaseId, args, function(data, response) {
restResponse = data;
console.log(data);
});
console.log(restResponse);
}
};
关于我在做什么错误restResponse变量的想法。