Выдаёт ошибку
[vuex] unknown mutation type: setUser
.
const state = {
user:{
}
},
getters = {
},actions = {
getUser(){
axios.get("/api/v1/user/current")
.then(response=>{
this.commit('setUser', response.data);
})
},
loginUser({}, user){
axios.get('/sanctum/csrf-cookie').then(response => {
axios.post('/api/v1/user/login', {
email: user.email,
password: user.password
}).then(response=>{
console.log(response.data);
localStorage.setItem(
"token",
response.data.access_token
)
})
});
}
},
mutations = {
setUser(state,data){
state.user = data;
}
};
export default {
namespaced: true,
state,
getters,
actions,
mutations
}
created() {
axios.defaults.headers.common['Authorization'] = "Bearer "+localStorage.getItem('token');
this.$store.dispatch('currentUser/getUser');
}