mafortis
mafortis

Reputation: 7138

vuejs make array of objects data

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.

Code

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)
    });
},

Screenshot

here is result of console codes above

one

any idea?

Upvotes: 1

Views: 324

Answers (1)

KingKabyle
KingKabyle

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

Related Questions