[Vuejs]-Get id in array from array object in vue js

0๐Ÿ‘

If I understood correctly your question, this.item is holding an object retrieved from the array. If is like this, it should be as easy as:

  .get("items/" + this.item.id)

0๐Ÿ‘

if you want to create new array you can do this at your return from axios

.then(res => {
  let arr = res.data
  this.xtra = arr.map(x =>
  x.item.id)

 })

0๐Ÿ‘

First declare Items as reactive array in setup function

 const tools = reactive([]);   

Then in methods, retrieve

axios.get("/user-items").then(response => {
                            
       var items = [];
       response.data.forEach((item, index) => {
           items.push(item.id);
       })
       Object.assign(this.items, items);
                        
});

Leave a comment