-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pinia and useFetch not working together in component #601
Comments
A workaround is to not access the store in the template directly, but to use computed properties. |
@danielroe See https://codesandbox.io/s/amazing-visvesvaraya-n6etwp?file=/pages/index.vue for a reproduction. |
Yes, this is an unavoidable consequence of the Nuxt 2 fetch implementation (which entails stringifying the entire component state). I'd recommend avoiding |
@Paalt I have used the |
Can someone more knowledgeable explain what the downsides of using Basically, am I safe in assuming that if |
I am using Pinia for state management but there seem to be a compatibility issue with composition-api. Specifically the useFetch function.
The error happens when I am using useFetch in my setup function and return an imported Pinia store to the template and refreshes the page. (It works fine when navigating to the page)
This will result in:
Steps to reproduce the behavior:
@pinia/nuxt": "0.1.8",
"@nuxtjs/composition-api": "0.31.0",
"nuxt": "2.15.8",
In a component:
Removing store from the return statement makes everything work fine again. So you can have both pinia store and useFetch in setup function as long as you dont use store in the template. But you often have the need for both.
The text was updated successfully, but these errors were encountered: