I am working with Vue & Vuex, making a fairly simple axios DELETE
call to the server inside of a promise.
I noticed that the DELETE
call was working correctly, the Vuex commit was also working, however my resolve was not.
I got everything to work by placing the resolve() BEFORE my commit(), however I do not understand WHY it needs to happen this way.
Hopefully someone has an answer so I can learn. See code below, and thank you in advance.
export const remove = ({ state, commit }, uid) => {
return new Promise((resolve, reject) => {
t.$axios.delete(t.$consts.DELETE_URL + '/' + uid).then((response) => {
if (response.status === 200) {
resolve()
commit('remove', uid)
}
}).catch((error) => {
reject(error.response)
})
})
}