4

I start my simple project with VueJS and Vuex. And I have a problem witch calling method from store. When I click my button in console I see this error

Uncaught TypeError: Cannot read property 'dispatch' of undefined at VueComponent.onSignin

Here is my component with button which should call dispatch
Login component.

And here is my store index.js Vuex.Store

And here you can find full repo

I read many topics on another forum but I stil don't know why it is not work, because I do similar project few months ago and it works correctly.

4
  • I have noticed that in the Login component you call this.$store.dispatch('signUserIn') but in your vuex store in the actions there is not such an action. The only action is onUserLogin . You should make an action called signUserIn Commented Sep 12, 2018 at 19:07
  • Good attention, but it still doesn't work. I pushed again with correct name of action. Commented Sep 12, 2018 at 19:24
  • Can you please make also an update in action signUserIn(payload) to signUserIn(context,payload) and remove methods attribute in vuex store Commented Sep 12, 2018 at 19:34
  • Hmm I do this, and it still doesn't work. If I good remember you should have permission to update 'help' branch. Fell free to do this. Commented Sep 12, 2018 at 19:58

1 Answer 1

4

Your store should be:

export default new Vuex.Store({

and not

export const store = new Vuex.Store({

Sign up to request clarification or add additional context in comments.

2 Comments

Yes, it is! Now it works. Thank you very much. I felt that is something small, but important. I have to small reputation to give +1 for your answer.
Great! can you mark the answer as correct for future reference? thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.