[useFetch] Component is already mounted, please use $fetch instead.
Hi,
I am using useFetch to load a product on the server side once... works fine, but the user can change the region and then price/taxe change, so the product has to be reloaded. this causes this error... Should I just duplicate the function and rename it to reFetchProduct and use $fetch or are there other solutions for this use case?
I am using useFetch to load a product on the server side once... works fine, but the user can change the region and then price/taxe change, so the product has to be reloaded. this causes this error... Should I just duplicate the function and rename it to reFetchProduct and use $fetch or are there other solutions for this use case?
11 Replies
how do you call
getProduct
is the interesting questionAlexander Lichter
YouTube
You are using useFetch WRONG! (I hope you don't)
💪🏻 useFetch is a mighty composable to fetch data in your Nuxt.js application. It can do so many things, from updating state to refreshing calls easily and even data caching is possible. But often I see that people misuse useFetch because it is so tempting to use all the features, even when you shouldn't. In this video I show the most common mist...
in the product page I call this action from my pinia store
getProduct
should be a composable and called as one but you are using it inside a "normal" function, causing the problem
See the video above 👍just watching 😉
thanks for the video 😉
my composable looks like this. I have only the problem that the url is no more reactive...
Do you have any idea how I can get around this?
because you lose reactivity, yes.
https://www.youtube.com/watch?v=sccsXulqMX8
Alexander Lichter
YouTube
Avoid losing Reactivity in your Vue Application
🔄 Reactivity is a crucial and and concept when building any kind of Vue application. But especially with the Composition API, I see more and more people having trouble with Reactivity and ensure that the "reactivity chain" will be kept up throughout various composables and components. In this video, I want to highlight typical issues with ref's ...
😄
hmm understood, but also not understood in my case 😂
tried to make the whole object reative...
and also this with getter
but no success...
params should be a computed
And you can use the
params
option of useFetch instead of passing it like you do rnthanks works perfect now 😉 and with params option is much better to read, thanks alot 😉
you are welcome 👏