Vuex-module-decorators: Rejected action throws ERR_ACTION_ACCESS_UNDEFINED

Created on 26 Sep 2018  路  4Comments  路  Source: championswimmer/vuex-module-decorators

The following login action will produce "ERR_ACTION_ACCESS_UNDEFINED" exception (see callstack below). The original rejection reason is lost.

@Module({name: 'auth', namespaced: true})
export default class AuthModule extends VuexModule {

@Action
  async login(payload: any): Promise<any> {
     return Promise.reject('login failed');
  }
}

ERR_ACTION_ACCESS_UNDEFINED: Are you trying to access this.someMutation() or this.someGetter inside an @Action?
That works only in dynamic modules.
If not dynamic use this.context.commit("mutationName", payload) and this.context.getters["getterName"]
Error: Could not perform action login
at Store.eval (webpack-internal:///./node_modules/vuex-module-decorators/dist/esm/index.js:311:33)
at step (webpack-internal:///./node_modules/vuex-module-decorators/dist/esm/index.js:96:23)
at Object.eval [as throw] (webpack-internal:///./node_modules/vuex-module-decorators/dist/esm/index.js:77:53)
at rejected (webpack-internal:///./node_modules/vuex-module-decorators/dist/esm/index.js:68:65)
undefined

bug

Most helpful comment

Is there a way to enable rawError: true by default without manually adding it to every action?

All 4 comments

now you can set rawError option to get your error thrown, not wrapped by the module.

works - thanks!

Is there a way to enable rawError: true by default without manually adding it to every action?

Any reason for the option rawError.
It simply overwrite my errors, and getting me confused, and take more time to troubleshot.

Was this page helpful?
0 / 5 - 0 ratings