question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Namespaces do not function. Throws "ERR_ACTION_ACCESS_UNDEFINED" when using namespaces

See original GitHub issue

I setup namespaces for my Vuex modules, and after that the following error is thrown whenever I try and access an action:

ERR_ACTION_ACCESS_UNDEFINED: Are you trying to access this.someMutation() or this.someGetter inside an @Action? That works only in dynamic modules.

Vuex Module:

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

  accounts: AccountModel[] = [];

  @Mutation
  SetAccounts(accounts: AccountModel[]){
    this.accounts = accounts;
  }

  @Action({commit: 'SetAccounts'})
  FetchAll(){
    axios.get('/api/accounts').then((response) => {
      return response.data;
    })
  }
}

Store initialization:

Vue.use(Vuex);

export default new Vuex.Store({
    state:{},
    modules:{
        Accounts: AccountStore
    }
})

Calling It:

this.$store.dispatch('Accounts/FetchAll');

If I remove the namespace bits and call this.$store.dispatch(FetchAll'); it works as expected.

I assume this is a problem with my usage of this?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:11
  • Comments:19 (1 by maintainers)

github_iconTop GitHub Comments

81reactions
andredewaardcommented, Jan 25, 2019

@Action({ rawError: true }) You can add this to the decorator. I think the decorator catches every error that happens inside the action and just give you this error. I had the same thing.

15reactions
Uninencommented, Feb 15, 2019

Edit: turns out there was a problem with my main component class and after I fixed it, the problem went away.


I’m getting this same error when trying to namespace modules. Without namespacing everything works fine.

My super simple store:

@Module({ namespaced: true, name: 'hoyci' })
export default class HoyciModule extends VuexModule {
  year = 0

  @Mutation
  setYear(year: number) {
    this.year = year
  }

  @Action({})
  init() {
    const d = new Date()
    this.context.commit('setYear', d.getFullYear())
  }
}

If I add rawError: true I get: “Unhandled promise rejection Error: “ERR_STORE_NOT_PROVIDED: To use getModule(), either the module should be decorated with store in decorator, i.e. @Module({store: store}) or store should be passed when calling getModule(), i.e. getModule(MyModule, this.$store)””

Using Vue 2.6.6 and vuex 3.1.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error "A namespace does not directly contain members ...
I'm trying to build my C# project and I'm getting the error message "A namespace does not directly contain members such as fields...
Read more >
FAQ: things you need to know about namespaces - Manual
How do I use namespaces classes functions, or constants in their own namespace? ... Namespaces do not affect any existing code in any...
Read more >
Namespaces and friends (C++ only)
Attempting to call function f() through class X using the A::X::f(x); call results in a compiler error. Since the friend declaration first occurs...
Read more >
Documentation - Namespaces
How TypeScript namespaces work. ... “Internal modules” are now “namespaces”. ... we can keep track of our types and not worry about name...
Read more >
Never got javascript Namespaces. Doesn't seem to work
afaik you can't use let to define a namespace, you need to use var. also you have "name" after function that is not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found