Chartjs-Vuejs, how to build an object?

1👍

Suppose that you have data property initialized as an empty array:

data(){
  return {
   data: [],

  }
}

Then update it with result coming from API :

 axios
          .get('../api/civitasnomen/' + this.searchInputcivitas)
          .then(response => {
             this.data.push({
               name:'data1',
               data:response.data.map(item => {
              return [item.lemme, item.nb];
            })
            })
          })

        axios
          .get('../api/civitascognomen/' + this.searchInputcivitas)
          .then(response => {
             this.data.push({
               name:'data2',
               data:response.data.map(item => {
              return [item.lemme, item.nb];
            })
          })

Leave a comment