NuxtN
Nuxt3y ago
Flinty

useLazyFetch force refetch

Hey, all. Just making the move to Nuxt 3.

I use useLazyFetch to fetch data on the client side/display loading screens. If I have 2 of these requests on one page, on the data from the first request is returned, and then the data is not refetched when navigating back to the page.

I'm doing the below currently:
let {data:data, pending, refresh:refresh, error} = await useLazyFetch(url, {initialCache: null, key: Math.random().toString()})
Surely this can't be the optimal solution to forcing the data to be refetched each time? Opinions welcome, I know this isn't right

Cheers!
Was this page helpful?