When a button is clicked by the user, I aim to update the data in my vuex store with the information from my local object. However, I am facing an issue with the mutation process. Below you can find some code snippets for better understanding.
The following method is executed upon clicking the button. (this.tableview is a local object containing identical values as the vuex object)
updateVuexTableview() {
// eslint-disable-next-line no-console
console.log("Update Vuex Table view");
this.updateTableview(this.tableview)
}
Within this method, the vuex action is invoked. Here is what the action looks like: (updTableview represents the new data that I intend to insert)
async updateTableview({commit}, updTableview) {
const response = await axios.put(
`http://localhost:3000/tableview`,
updTableview
);
// eslint-disable-next-line no-console
console.log(response.data);
commit('updateTableviewMut', response.data);
},
This is the problematic mutation function being called. Despite attempting to pop and push the data again, I have yet to find a working solution.
updateTableviewMut: (state, updTableview) => {
state.tableview.push(updTableview)
},
Below is how my state is defined:
const state = {
tableview: {
"thema_c": true,
"status_c": true,
"priority_c": true,
"custom1_c": true,
"custom2_c": true,
"customFieldName1": "Custom1",
"customFieldName2": "Custom2"
},
};