I have a Vuex action which makes a GET request and then sets the value of a Vuex property to the response:
async getUserServers({commit, state, dispatch}, userId){
try {
let response = await axios.get("/servers/" + userId)
state.servers = response.data.servers
} catch (error) {
console.log(error)
}
}
As you can see, I don't use a mutation to set the state to my response, however, I read on the documentation that every change to the state should be done through mutation. I guess I have to change it to this:
async getUserServers({commit, state, dispatch}, userId){
try {
let response = await axios.get("/servers/" + userId)
commit('setServers', response.data.servers)
} catch (error) {
console.log(error)
}
}
I'm curious whether the first snippet of code would lead to some problems down the road.