I am running into an issue with this code:
let productBuyDataArray = [];
// productBuyData is a promise
productBuyData.then(function(result) {
for (let key in result) {
productBuyDataArray.push({
time: key,
value: result[key],
});
}
}
);
when I console.log(productBuyDataArray);
, it shows the data like I want it. But then when I try to use the data it is gone, the array is empty. I found out with console.log(JSON.stringify(productBuyDataArray));
that it is indeed empty. Can someone help me with this?