Chartjs-Vue-chartjs with axios for stacked bar chart

0👍

I think you are right about this.loaded = true. Try setting it once AFTER the second API call for data2.

However, the main problem appears to be a typo in your axios calls. You are setting data1 twice:

this.loaded = false
axios.get(`url`).then((response) => {
  this.data1 = response.data.xxx
  this.loaded = true
  axios.get(`url`).then((response) => {
    this.data1 = response.data.xxx
    this.loaded = true
  })
})

change the second axios get call to data2:

this.loaded = false
axios.get(`url`).then((response) => {
  this.data1 = response.data.xxx
  //this.loaded = true
  axios.get(`url`).then((response) => {
    this.data2 = response.data.xxx
    this.loaded = true
  })
})

Also, make sure that your URLs are different and correct in your actual code.

Leave a comment