Open marioch5 opened 3 years ago
having the same problem here!
const user = this.$api.auth.fetchUser();
I was able to access plugins like this:
const user = this.$store.app.$api.auth.fetchUser();
I think this is a cause of problem: https://github.com/michaelolof/vuex-class-component/blob/a4f1dc03f23b2eb4a714d2ac211f6303e031cac5/src/module.ts#L197
As a result this
in action bound to vuex restricted context with only dispatch, commit, etc as here: https://github.com/vuejs/vuex/blob/9039c2169634925682ffcb21c57f5df355e16ad1/src/store.js#L474
To fix that we need to provide full store object from this
instead of restricted context:
Object.defineProperty( proxy, "$store", { value: this });
I've implemented a fix, you can give it a try. If all will be fine I will open PR.
https://github.com/sandronimus/vuex-class-component/tree/store-fix
Merged. Thanks 👍 https://github.com/michaelolof/vuex-class-component/pull/105
I've implemented a fix, you can give it a try. If all will be fine I will open PR.
https://github.com/sandronimus/vuex-class-component/tree/store-fix
@michaelolof Thank you! Can you publish new version, please?
@sandronimus Here https://www.npmjs.com/package/vuex-class-component/v/2.3.6
Thanks
Hello! I am using nuxt and I can't seem to access my plugins on my action method body, am i doing something wrong??
I currently have my state set up like this:
store/index.ts
store/user.ts
plugin/storeProxies.ts
The problem is that when i call
await this.$vueStore.user.fetchLoggedUser();
on my component, i can't seem to find the app. When i access thethis
i can access the$store
but inside of it i cannot find the context. I need it to make a api call to fetch my user.Normally i would do something like
Am i missing something?? Thanks!