Chartjs-ChartJS loading errors from axios API call in Vue.js

0👍

The error comes from vue-chartjs; more precisely from line 60 of the function setDatasets, which is defined inside the file utils.ts.

The problem can most probably be solved if you change the following line of your code.

this.chartData = { labels: res.data.labels, dataset: [{ data: res.data.data }] }

Instead of dataset, specify datasets as follows:

this.chartData = { labels: res.data.labels, datasets: [{ data: res.data.data }] }

If this doesn’t help, the structure of res.data.data needs to be checked. Make sure, it complies with one of the formats expected by Chart.js.

Leave a comment