Hi Guys I’m using a HTML Canvas to create somes Charts with JS, I use Variables API REST and Values, Actually I get all values from specific variables using https://industrial.api.ubidots.com/api/v1.6/variables/${inVariableKey}/values/?page=1 before i filter the Array result with .filter taking as reference value timestamp but I think that it is not the better.
I would like filter te api result like https://industrial.api.ubidots.com/api/v1.6/variables/${inVariableKey}/values/timestamp__day__range=2022-04-03,2022-04-04
I am having as reference Variable Filters
ubidots.on('ready', function (data) {
const token = '';
const variableId = '';
getValuesFromVariable(variableId , token)
.then((dataResult) => {
console.log("getValuesFromVariable dataResult", dataResult);
})
.catch((error) => {
console.error("getValuesFromVariable error", error);
});
});
async function getValuesFromVariable(inVariableKey, inToken) {
const url = `https://industrial.api.ubidots.com/api/v1.6/variables/${inVariableKey}/values/`;
const response = await fetch(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'X-Auth-Token': inToken,
},
});
return response.json();
};