-
Notifications
You must be signed in to change notification settings - Fork 100
help: Before mount, await useFetch #741
Comments
Do you have a simple example that you could share that doesn't use custom functions like |
It can be anything, just |
What is your issue in the first place? Can you provide a reproduction and specify the steps to reproduce and expected behavior? Also are you doing SPA navigation? There is a lot of stuff to guess here and if you don't help us with all the needed information then we can't help you. Please do your share of the work if you expect help. |
Sorry, just finished with repro repo: Click on "Post" link. Page will show "LOADING" for 3 seconds after navigation.
Yes, I writed it before:
|
That's how fetch (useFetch) is supposed to work AFAIK. On SPA navigation it doesn't block page loading and it exposes If you expect the behavior where the page loading is blocked until full load then you should use asyncData ( See my CS that uses |
(BTW. If my codesandbox doesn't work the it's probably codesandboxes fault. Maybe download it and try locally) |
Here's a stackblitz we can use: https://stackblitz.com/edit/github-jc3ome. |
So
It's quite confusing given that it's called very similar to Here is a Nuxt 3 example that DOES block navigation: https://stackblitz.com/edit/github-jmkwfk?file=pages%2Findex.vue,package.json,pages%2Fposts%2Findex.vue And here is Nuxt 2 which doesn't: https://stackblitz.com/edit/github-jc3ome-osg6rc?file=pages%2Fposts%2Findex.vue I'm not sure if the intention is that the Options API is used when requiring |
Seems like this is not intended to work like Thus I would just use this issue for clarifying this in the documentation. |
So, what I should to do? |
Blocking route change with a composable is not supported by the Vue 2 composition API. This is why, when we rewrote Nuxt composables in Nuxt Bridge, we chose to use |
@danielroe Bridge still marked as not ready for production and have dependency issues in my project. |
I think you misunderstood. Bridge also doesn't support it. The |
📚 What are you trying to do? Please describe.
On the client, before component will be mounted, I want to completely load data.
🔍 What have you tried?
ℹ️ Additional context
According to Nuxt lifecycle, I expect that
useFetch
will be completely done, likefetch
does.This is especially distressing in
pageComponents
- page transition is complete, but page is empty and waiting for data.https://nuxtjs.org/_nuxt/image/de48ca.svg
The text was updated successfully, but these errors were encountered: