1

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?

1 Answer 1

2

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.