[Vuejs]-Vuejs โ€“ how to add array to the target data?

0๐Ÿ‘

As I understand, you just want to rename the keys of data objects you retrieve from the server.

This should do it:

getlist() {
  this.$http.get('/getlist')
    .then(res => {
      let list = [];
      for (let item of res.data) {
        let newItem = {
          category_name: item.name,
          companies: item.company
        }
        list.push(newItem);
      }
      this.lists = list;
    })
    .catch(err => {
      console.error('Error retrieving "/getlist":', err)
    });
}
๐Ÿ‘คuser9246109

Leave a comment