Currently, I have a Vuex action that performs a GET request and then assigns the response to a Vuex property:
async getUserServers({commit, state, dispatch}, userId){
try {
let response = await axios.get("/servers/" + userId)
state.servers = response.data.servers
} catch (error) {
console.log(error)
}
}
Although this setup works fine, according to the documentation, all state changes should be made through mutations. So, I'm thinking of updating it to look like 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 wonder if sticking with the initial code could cause any issues in the future.