Namespaces do not function. Throws "ERR_ACTION_ACCESS_UNDEFINED" when using namespaces
See original GitHub issueI 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:
- Created 5 years ago
- Reactions:11
- Comments:19 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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.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:
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