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 ponent with button which should call dispatch
Login ponent.
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.
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 ponent with button which should call dispatch
Login ponent.
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.
Share edited Sep 12, 2018 at 19:04 Bartlomiej Mroczek asked Sep 12, 2018 at 18:59 Bartlomiej MroczekBartlomiej Mroczek 1213 silver badges14 bronze badges 4- I have noticed that in the Login ponent 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 – gijoe Commented Sep 12, 2018 at 19:07
- Good attention, but it still doesn't work. I pushed again with correct name of action. – Bartlomiej Mroczek 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 – gijoe 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. – Bartlomiej Mroczek Commented Sep 12, 2018 at 19:58
1 Answer
Reset to default 4Your store should be:
export default new Vuex.Store({
and not
export const store = new Vuex.Store({