0

I've seen that this question have been asked a couple of time but I cannot find any good answer and don't understand why my code is behaving like this.

As said in the title I'm trying to import my store in the router to be able to use my getters on conditional and grant a user to access or not a route.

But as soon as i'm trying to import the store I get the following error:

[vuex] unknown action type: autoSignIn

this is coming from:

const vm = new Vue({
router,
store,
provide,
i18n,
render: handle => handle(App),
created () {

firebase.auth().onAuthStateChanged((user) => {
  if (user) {
    this.$store.dispatch('autoSignIn', user)
    this.$store.dispatch('loadMatter')
    this.$store.dispatch('loadFootprints')
    this.$store.dispatch('loadMembers')
  }
})

So I guess that when my app is starting the store hasn't loaded yet.

How can I workaround that I want to be able to use

store.getters.mygetter

Thank you very much

3 Answers 3

1

I think you need to import your store in your router file

I'm doing it like this:

import store from "@/store/index.js";
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for your answer, I'm already importing the store which is returning me this error
0

Are you using modules of vuex? Can you share your store index file?

https://vuex.vuejs.org/guide/modules.html

If you are using modules of vuex, you should do this.$store.dispatch('module_name/action_name')

2 Comments

I get store is undefined when I try to do this.$store.dispatch('module_name/action_name')
Can you create a git repo? so i can reproduce your error.
0

I have my store split into files

Vue.use(Vuex);

const store = new Vuex.Store({
  state,
  actions,
  mutations,
  getters,
  plugins: [
    process.env.NODE_ENV === 'development' && createLogger({ collapsed: false }),
  ].filter(Boolean),
});

export default store;

Comments

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.