You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was reading your article (great, btw!) and following along. I noticed that you specify the type as ActionTree<State, State> & Actions.
But if you wanted to do an action with a payload, such as a login function similar to: async [ActionTypes.Login]({ commit }, {username, password}) { AuthService.login(username, password).subscribe(res => { commit(MutationType.SetUsername, res.username); commit(MutationType.SetIsLoggedIn, true); }) }
You would recieve an error because the payload {username, password} was unexpected. Removing the & Actions stops the error.
I'm still pretty new to Vuex (and fully appreciating strong typing), am I approaching this incorrectly?
The text was updated successfully, but these errors were encountered:
I was reading your article (great, btw!) and following along. I noticed that you specify the type as
ActionTree<State, State> & Actions
.But if you wanted to do an action with a payload, such as a login function similar to:
async [ActionTypes.Login]({ commit }, {username, password}) { AuthService.login(username, password).subscribe(res => { commit(MutationType.SetUsername, res.username); commit(MutationType.SetIsLoggedIn, true); }) }
You would recieve an error because the payload {username, password} was unexpected. Removing the
& Actions
stops the error.I'm still pretty new to Vuex (and fully appreciating strong typing), am I approaching this incorrectly?
The text was updated successfully, but these errors were encountered: