Fetching data on server side in generate mode #1160
Unanswered
anatolykopyl
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I can't figure out a way to fetch data during static site generation and have it persist to the client side.
The fetching is happening inside of a composable that wraps
useFetchand is widely used across the app.Here's the ways I tried to migrate this composable:
useLazyAsyncDataThis seemed like the most straight forward way of doing things, but the client first sees the page without the fetched data.
useLazyAsyncData+onServerPrefetchThen I tried to call the
refreshfunction fromuseLazyAsyncDatainonServerPrefetch. Still no initial data on client.useStateAn alternative way I tried is to have a
useStateref and fetch data manually inonServerPrefetch. Still nothing.This is something I've been fighting with for a pretty long time now, so any advice would be appreciated!
Beta Was this translation helpful? Give feedback.
All reactions