0👍
Put all your API calls inside Actions in your Vuex store. This way every change that gets committed to your state only comes from inside the store and makes it easier for you to debug and make the code easier to understand.
Now to use axios you should do something like this:
state = {
//
},
getters = {
//
},
mutations = {
SET_TERM : (state,payload) => {
state.term = payload
}
},
actions = {
CREATE_TERM : async (context,payload) => {
let { data } = await Axios.get('/path/to/api/')
context.commit('SET_TODO',data)
}
}
Please read this awesome article for more explanations and details.
Source:stackexchange.com