N
Nuxtβ€’5mo ago
PeterK

Data Fetching Skill issues ? πŸ€”

Hi everyone πŸ‘‹ So I am working on my project with Nuxt and I am experience some issues, which for the world I can not resolve. So I have this pages/[page].vue page where I am using data loader (but useAsyncData and useFetch yield the same result) and the goal is simple, user navigate to this page, we load the data from database and display them. The loader works, we get our data. πŸŽ‰ However. The initial request, so when I open the http://localhost:3000/[page] is blocked. Or rather the navigation to the page is blocked, until the Promise is resolved. And the pending <PageSkeleton /> is not shown. Now I have tried the same set-up in Next.js where the initial request is blocked as well, however you can use loading.tsx component to display loading state, or in layout.tsx wrap the page component in <Suspense /> and display fallback loading skeleton. So naturally, I did exactly that, I wrapped the <div><slot /></div> in <Suspense /> and nothing happened. I moved the whole data loading and displaying to separate component and wrapped that one in <Suspense /> on the pages/[page].vue page. I have tried useLazyFetch, useLazyAsyncData and everything yields the same result, the inital request is always blocked/ no loading skeleton displayed. I guess these are just skill issues, but could someone help me with this one? Code snippets could be found https://github.com/nuxt/nuxt/discussions/27872 Thank you
Nuxt Image
Server Loaders - Form Actions
Use server loaders to load data in your pages and components.
GitHub
Data Fetching Skill issues ? πŸ€” Β· nuxt nuxt Β· Discussion #27872
Hi everyone πŸ‘‹ So I am working on my project with Nuxt and I am experience some issues, which for the world I can not resolve. So I have this pages/[page].vue page where I am using data loader (but ...
5 Replies
dwol
dwolβ€’5mo ago
what happens if you log the pending/loading state? watchEffect(() => console.log(pending.value)) maybe the request is being completed before the page is mounted so youre never seeing the loading state? not sure
PeterK
PeterKOPβ€’5mo ago
Hi Dwol πŸ‘‹ Yeah so, I have added the good old await new Promise((r) => setTimeout(r, 5000)) And I am waiting for the initial response until this promise is resolve. On subsequest client navigaiton, the loading skeleton is displayed, however the initial request (or page refreshed) is blocked for at least 5 seconds
manniL
manniLβ€’5mo ago
That should be correct behavior as Nuxt does not support streaming responses So you have to await until SSR is fully done to display the fully rendered page
PeterK
PeterKOPβ€’5mo ago
Hi Alex πŸ‘‹ Thank you for explanation 😎 - love your videos btw. So, is there a way to stream response in Nuxt / is it on Roadmap? And the workaround could be to fetch data on client only right
manniL
manniLβ€’5mo ago
thanks πŸ™ This is definitely something we want to look into but no ETA Yes, though SEO might suffer under that
Want results from more Discord servers?
Add your server