'Chart.js won't show data if I remove console.log()
If I try to log something else it again stops working. I tried putting it at the end of the function and it works. It has to be there. What's going on?
async function fetchData() {
const response = await client.query(query).toPromise();
setPoolSnapshots(response.data.poolSnapshots);
console.log(poolSnapshots[0].totalLiquidity); //breaks without this line.
poolSnapshots?.map((poolInfo, _index) => (
dates.push(poolInfo.timestamp),
swapFeesEarned.push(poolInfo.swapFees24h)
))
swapFeesEarned?.map((swapFee, _index) => (
swapFeesApr.push((swapFee *365) / poolSnapshots[_index].totalLiquidity * 100)
))
dates?.map((date, _index) => (
dates[_index] = new Date(date * 1000).toLocaleDateString()
))
};
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
