Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useFetch and useAsyncData loading twice (SSR & Client) when inside a dynamic loaded component #27439

Closed
swissmexxa opened this issue Jun 4, 2024 · 3 comments

Comments

@swissmexxa
Copy link

Environment


  • Operating System: Linux
  • Node Version: v18.20.3
  • Nuxt Version: 3.11.2
  • CLI Version: 3.11.1
  • Nitro Version: 2.9.6
  • Package Manager: npm@10.2.3
  • Builder: -
  • User Config: devtools
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-5jqx3p?file=pages%2Findex.vue

Reload the index page and see that https://jsonplaceholder.typicode.com/posts is called again on client side although the data is present in the payload data.

Describe the bug

When using useFetch or useAsyncData inside a component which is inserted into the DOM by a dynamic component, useFetch or useAsyncData won't use the data from the payload but calls the API endpoint again on client side which results in two calls to the REST API endpoint (SSR and Client). It should take the data from the payload instead of making another call on client side.

image

Additional context

This problem is crucial when working with Storyblok CMS as Storyblok mainly works with dynamic components.

Logs

No response

Copy link

stackblitz bot commented Jun 4, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@bitbytebit1
Copy link

Can you try setting a key for useFetch?

@danielroe
Copy link
Member

danielroe commented Jun 20, 2024

Let's track in #18405. (It's an upstream vue bug.)

@danielroe danielroe closed this as not planned Won't fix, can't repro, duplicate, stale Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants