Reputation: 7138
I have array of data (selected items) and I need to extract ids of this array into new array so I can send those ids only to back-end.
method
toggleSelection(rows) {
console.log('this.multipleSelection : ',this.multipleSelection); // prints my default array (include all data)
this.multipleSelection.forEach(row => {
console.log('rows: ', row) // get each object of array (extract ids here)
// send axios request to backend (ids only)
});
},
here is result of console codes above
any idea?
Upvotes: 1
Views: 324
Reputation: 381
At first I need to say I never worked with Vue.js. But in simple vanilla-javascript you could use the map function. I don't know if this works but Here is a possible answer:
yourids = this.multipleSelection.map(row => row.id);
Upvotes: 2