question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The data returned by useFetch has contents, but the value is null where lazy is true

See original GitHub issue

Environment


  • 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, Uploading image.png…

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:closed
  • Created a year ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
qyn980427commented, Aug 8, 2022

I appreciate that, brother!

0reactions
CapitaineToinoncommented, Aug 8, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found