我需要你的帮助。有没有办法在函数外调用局部变量?
代码
var ubidots = require('ubidots');
var client = ubidots.createClient('***API Key***');
var overview = client.auth(function () {
var tempData = this.getVariable('**Key**'); // Temperature Variable ID
var humidData = this.getVariable('**Key**'); // Humidity Variable ID
var lightData = this.getVariable('**Key**'); // Light Variable ID
var soilData = this.getVariable('**Key**'); // Soil Moisture Variable ID
tempData.getValues(function (err, data) {
var tempValue = data.results[0].value;
});
humidData.getValues(function (err, data) {
var humidValue = data.results[0].value;
});
lightData.getValues(function (err, data) {
var lightValue = data.results[0].value;
});
soilData.getValues(function (err, data) {
var soilValue = data.results[0].value;
});
});
console.log(tempValue);
console.log(humidValue);
console.log(lightValue);
console.log(soilValue);
如何打印tempValue
,humidValue
,lightValue
&的价值? soilValue
?
你的帮助很大!