Server side fetch refetches on client 3 times
I call
useFetch()
in 3 components and when I do switch locale it refetches 3 times on client. Why? Shouldn't it cached after 1st call?
I followed recipe on nuxt docs so I got:
Custom fetch
Composable
API method
4 Replies
Anyone?
Nesting useFetch composables most of the time is a bad idea, they generally should be top level
it not retriggering hint's towards it not being bound properly to a setup function, as that should rerun on locale change. (assuming the locale is part of the url and you don't have custom :keys set)
So there is no way in nuxt to fetch some data here and there and it auto deduped repeatable calls? Like in tanstack query? So I should fetch it on top and pass through 5+ components?
You can do that just fine, however they way you are registering it is probably the issue
https://nuxt.com/docs/api/composables/use-fetch#params
getCachedData
, key
and dedupe
are all things to consider