access state from action vuex code example
Example 1: vuex access getters from actions
getters: {
getAppData: state => () => {
return state.data;
}
}
actions: {
sendDataToServer({ commit , getters }, payload) {
// call getter
const data = getters.getAppData
}
},
Example 2: getter in action vuex
this.getters["store/getNameStore"]
Example 3: vue store access state in actions
actions: {
actionName ({ commit, state }, payload) {
console.log(state)
}
}