You will need to add some console.log() debug statements to better understand what’s happening.
I would suggest that it’s better to see if you have results by checking the length of the returned items:
Instead of this:
.then((results) => {
let rowParam = results.items[0];
If there are no items, you will end up with an undefined runtime error.
You want something like this (not tested):
.then((results) => {
if(results.items.length > 0) {
// do stuff with the results
let rowParam = results.items[0];
return{
"total": rowParam.cout,
"period": rowParam.period
};
}
else {
return{
"total": 0,
"period": []
};
}