Vuex-module-decorators: Did anyone manage to solve this problem? As others in this thread, I get the error following error `ERR_ACTION_ACCESS_UNDEFINED` with `rawError: false` and `ERR_STORE_NOT_PROVIDED` with `rawError: true` if I try to call a namespaced action.

Created on 10 Nov 2019  路  2Comments  路  Source: championswimmer/vuex-module-decorators

Did anyone manage to solve this problem? As others in this thread, I get the error following error ERR_ACTION_ACCESS_UNDEFINED with rawError: false and ERR_STORE_NOT_PROVIDED with rawError: true if I try to call a namespaced action.

// In some component
connect() {
  this.$store.dispatch('Connection/testAction'); // Error
}

...

// In connection store
@Module({ namespaced: true, name: 'Connection'})
export default class Connection extends VuexModule {
  @Action({ rawError: true })
  testAction() {
    console.log('test action');
  }
}

If I use the getModule function before calling the action, the error does not occur.

connect() {
  const connection = getModule(Connection, this.$store);
  connection.testAction() // This works fine - Ouput: "test action"
  this.$store.dispatch('Connection/testAction'); // This also works fine! - Output: "test action
}

So this is an fix to the problem, but I wouldn't say it's an optimal solution. This really seems like a bug to me.

_Originally posted by @holwech in https://github.com/championswimmer/vuex-module-decorators/issues/86#issuecomment-506698275_

All 2 comments

That is the way you are supposed to use the plugin. You can avoid using getModule() before calling your action if you export your Vuex module like this:

class Connection extends VuexModule {
...
}
export default getModule(Connection);

You might have to also use the param dynamic: true in your @Module decorator, I am not sure.

@stephane303 feel free to close this issue if that solved your problem :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

souphuhn picture souphuhn  路  5Comments

webcoderkz picture webcoderkz  路  6Comments

MagnusJohansson picture MagnusJohansson  路  5Comments

blainehansen picture blainehansen  路  4Comments

BonBonSlick picture BonBonSlick  路  5Comments