I'm calling a store action from the main layout (nuxt.js default.vue) I'm then calling a state mutation within the mutations export. Why am I getting this error?
Error in console: http://prntscr.com/rwvfjf
Code:
default.vue
created () {
this.$store.dispatch("update_user");
...
}
Store (store/index.js)
export const state = {
...
state: null,
}
export const actions {
...
update_user({commit}) {commit("update_user")}
}
export const mutations = {
async update_user(state) {
if (state.token == undefined) {
return
}
if (this.$axios.defaults.headers.common["authorization"] == undefined) {
this.$axios.defaults.headers.common["authorization"] = state.token
}
var user = await this.$axios.get("/api/v1/user/@me");
state.user = user;
},
}