I store data in state as array and I want to change the value of the object. How can I change the id 1 value to true with vuex actions?
state.js
const array=[]
mutations.js
storeArray(state, data) {
state.array = data;
}
actions.js
async changeValue({ state, dispatch, commit }, id) {
const item = await state.array[id].value;
await commit('storeArray', { value: true });
},
array looks like
[{
id: "1",
value: 'false'
}, {
id: "2",
value: 'true'
}]
array
. You rather want to loop through all elements, check which one is the desired element/index and adjust that data accordingly. - Aer0