I'm try to remove an Object inside my nested(Object->Array->Objcet) vuex state.
The scenario of my application is so:
1. I will send the request to the back-end to delete a record and then return a response with just a message. Then commit to vuex stateUNASSIGN_COURS_AND_TEACHER_TO_CLASSROOM
. Everything here works fine.
async unassignCoursandTeacher({ commit }, classroom) {
let response = await Axios.post(
"/dashboard/school/unassignCoursandTeacher/" + classroom.id, classroom
);
let cls = response.data;
if (
response.status == 200 ||
response.status == 201 ||
response.status == 204
) {
commit("UNASSIGN_COURS_AND_TEACHER_TO_CLASSROOM", cls);
return cls;
}
}
Now I want to updated
singleClassroom
State with the help of mutations. But it doesn't remove the delete item in State. Only if I refresh the page. below is how the mutation is setup.`UNASSIGN_COURS_AND_TEACHER_TO_CLASSROOM(state, cls) { let cours = state.singleClassroom.courses.filter(c => c.id != cls); state.singleClassroom.courses = cours; }`