I need your guys help on this. Is there any way to call a local variable outside a function?
Code
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);
How can I prrint out the value of tempValue
, humidValue
, lightValue
& soilValue
?
Your help is much appriciated!