2👍
Mutations accept only two parameters: first – state, second – payload. If you want to pass multiple parameters in payload use an object.
commit('auth_success', { token, user })
The in mutations:
auth_success(state, payload){
const { token, user } = payload
state.status = 'success'
state.token = token
state.user = user
},
- [Vuejs]-Vue+Vuetify+Nuxt – Render a list of components in a v-for loop
- [Vuejs]-How to show dropdown with placeholder in v-for in Vue?
1👍
Mutations expect two arguments: state and payload, where the current state of the store is passed by Vuex itself as the first argument and the second argument holds any parameters you need to pass.
You need to destructure the auth_success
mutations parameters:
auth_success(state, { token, user }){
state.status = 'success'
state.token = token
state.user = user
},
Quote reference: Vuex – passing multiple parameters to mutation
Source:stackexchange.com