4👍
✅
The first parameter of the action is the context
, which has functions like commit
and dispatch
. You extract (destructuring assignment) the dispatch
by using { dispatch }
as your parameter. You can use { dispatch, commit }
to fix this and actually assign commit to a local variable.
destructuring assignment
async login({ dispatch, commit }, user) {
commit('your_mutation')
}
using context
async login(context, user) {
context.commit('your_mutation')
}
Source:stackexchange.com