Answer the question
In order to leave comments, you need to log in
Why does the "delete" button fire after multiple page reloads?
Hello, there was a problem, the delete button only works when I reload the page 2-3 times, and before that it displays an error:
TypeError: Cannot read properties of undefined (reading 'filter')
at Proxy.removeContact (App.vue:52:45)
async removeContact(id) {
await this.$store.dispatch('DEL_CONTACTS', id);
this.contacts = this.contacts.filter(c => c.id !== id);
},
DEL_CONTACTS: async (context, id) => {
await axios.delete(`/api/contacts/${id}`);
context.commit("REMOVE_CONTACTS", id)
}
REMOVE_CONTACTS: (state, id) => {
state.contacts = state.contacts.filter(c => c.id !== id);
},
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question