championswimmer / vuex-module-decorators

TypeScript/ES7 Decorators to create Vuex modules declaratively
https://championswimmer.in/vuex-module-decorators/
MIT License
1.8k stars 170 forks source link

Action without mutations #321

Open kosratdev opened 4 years ago

kosratdev commented 4 years ago

I always use vuex actions to send requests via axios and then if the request response needs to be stored in the state I will mutate it if not I will return the response. I have used Vuex before with the above strategy without any errors but when I use this library it errors with the following error message:

Error: 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"]
hisuwh commented 3 years ago

I'm getting this to

lextract commented 3 years ago

I'm using Nuxt and I've used vuex-module-decorators with actions, mutations, etc, and It was working right. I've included the nuxt/auth-next to the project and the ERR_ACTION_ACCESS_UNDEFINED error starts to happen. If I remove the dependency then everything works right again.

I think there are two paths to initialize the store, some one should be affecting the other one. Still, I don't know what to do.

0Ncoder0 commented 3 years ago

Some thing in your code went wrong and thrown an error , @Action caught it and thought that you were using some mutation or getter , use try/catch to catch your own error before @Action did

kennymalac commented 3 years ago

Some thing in your code went wrong and thrown an error , @action caught it and thought that you were using some mutation or getter , use try/catch to catch your own error before @action did

nope, even with console.log inside of @Action with no mutation, the console.log does not fire. This seems to be a new bug as this did not happen before.

0Ncoder0 commented 3 years ago

Some thing in your code went wrong and thrown an error , @action caught it and thought that you were using some mutation or getter , use try/catch to catch your own error before @action did

nope, even with console.log inside of @action with no mutation, the console.log does not fire. This seems to be a new bug as this did not happen before.

try Action({ rawError : true }) options ,and look what comes out

xddq commented 3 years ago

@kennymalac and all others with this problem. Can confirm this issue.

With "@nuxtjs/auth-next": "5.0.0-1618898588.9655d0e", and "vue-property-decorator": "^9.1.2" and "nuxt-property-decorator": "^2.9.1"

you can go to your nuxt.config.js file and auth: { vuex: false }

to fix this weird issue. No idea why it is happening tho : ]