The data returned by useFetch has contents, but the value is null where lazy is true
See original GitHub issueEnvironment
- Operating System:
Windows_NT
- Node Version:
v14.17.5
- Nuxt Version:
3.0.0-rc.6
- Package Manager:
npm@6.14.14
- Builder:
vite
- User Config:
alias
,runtimeConfig
,css
,modules
,postcss
,autoImports
,hooks
- Runtime Modules:
@nuxtjs/tailwindcss@5.3.1
,@pinia/nuxt@0.3.1
,@vueuse/nuxt@8.9.4
- Build Modules:
-
Reproduction
https://stackblitz.com/edit/github-svkc8u?file=pages%2Findex.vue,pages%2Ftest.vue
Describe the bug
When you go to the test page and you go back to the index page through nuxtLink, you get this situation that I just described,
Additional context
I am not sure if this problem occurs only when lazy is true. I have encountered the situation that the data has content but the value cannot be obtained for several times. At present, it will occur in the demo I provided
step: 1.The URL directly accesses /test 2.Go back to Index via Nuxtlink 3.To view the log
Logs
No response
Issue Analytics
- State:
- Created a year ago
- Comments:5
Top Results From Across the Web
`useFetch` data return null with mismatching client ... - GitHub
If I give the local URL, it returns null. Also interesting is that $fetch , returns completely correct data and useFetch returns null....
Read more >useFetch custom hooks is somehow returning data twice how ...
log the data that I fetched there are two outputs, one of them has value null, and the other is the data that...
Read more >Data Fetching · Get Started with Nuxt
Nuxt provides useFetch, useLazyFetch, useAsyncData and useLazyAsyncData to ... the situation where the data is null (or whatever value you have provided in ......
Read more >Queries - Apollo GraphQL Docs
If true , the query can return partial results from the cache if the cache doesn't contain results for all queried fields. The...
Read more >Suspense for Data Fetching (Experimental) - React
We call this approach “fetch-on-render” because it doesn't start fetching until after the component has rendered on the screen. This leads to a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I appreciate that, brother!
I suggest you read the data fetching section of nuxt 3’s documentation for ways to deal with this. Either you will rely on a lazy solution, in which case you will need to deal with the data being null for a while, or you don’t use a lazy solution but your fetch will block navigation until data is there.