Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] - Action Typing and Payloads #1

Open
gabrielthomasjacobs opened this issue May 11, 2021 · 0 comments
Open

[Question] - Action Typing and Payloads #1

gabrielthomasjacobs opened this issue May 11, 2021 · 0 comments

Comments

@gabrielthomasjacobs
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant