N
Nuxt2y 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()})
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!
5 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Flinty
Flinty2y ago
Good question 3.0.0 rc11 @Sr. Full Stack Dev
Flinty
Flinty2y ago
No description
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Flinty
Flinty2y ago
Ah okay, will give it a go thank you Running npx nuxi upgrade has caused a build error:
ERROR Cannot start nuxt: Cannot read properties of undefined (reading 'push') 13:16:41

at node_modules/@nuxtjs/tailwindcss/dist/module.mjs:125:56
at Array.forEach (<anonymous>)
at setup (node_modules/@nuxtjs/tailwindcss/dist/module.mjs:125:19)
at async normalizedModule (node_modules/@nuxt/kit/dist/index.mjs:167:5)
at async installModule (node_modules/@nuxt/kit/dist/index.mjs:435:15)
at async initNuxt (node_modules/nuxt/dist/index.mjs:2256:7)
at async load (node_modules/nuxi/dist/chunks/dev.mjs:6810:9)
at async Object.invoke (node_modules/nuxi/dist/chunks/dev.mjs:6871:5)
at async _main (node_modules/nuxi/dist/cli.mjs:50:20)
ERROR Cannot start nuxt: Cannot read properties of undefined (reading 'push') 13:16:41

at node_modules/@nuxtjs/tailwindcss/dist/module.mjs:125:56
at Array.forEach (<anonymous>)
at setup (node_modules/@nuxtjs/tailwindcss/dist/module.mjs:125:19)
at async normalizedModule (node_modules/@nuxt/kit/dist/index.mjs:167:5)
at async installModule (node_modules/@nuxt/kit/dist/index.mjs:435:15)
at async initNuxt (node_modules/nuxt/dist/index.mjs:2256:7)
at async load (node_modules/nuxi/dist/chunks/dev.mjs:6810:9)
at async Object.invoke (node_modules/nuxi/dist/chunks/dev.mjs:6871:5)
at async _main (node_modules/nuxi/dist/cli.mjs:50:20)
Okay yeah, got that fixed. Killed page transitions tho
Want results from more Discord servers?
Add your server