on initial client side load with `server: false`, useFetch does not await data fetching
See original GitHub issueEnvironment
Operating System: Darwin Node Version: v17.2.0 Nuxt Version: 3.0.0-27491748.3186841 Package Manager: yarn@1.22.10 Builder: vite User Config: - Runtime Modules: - Build Modules: -
Reproduction
https://codesandbox.io/s/unruffled-rain-zzuixq?file=/app.vue
Describe the bug
When using useFetch composable inside setup method or inside any lifecycle hook then it directly shows error. It does not even hit the backend api.
Additional context
No response
Logs
RefImpl {
__v_isShallow: false,
dep: undefined,
__v_isRef: true,
_rawValue: null,
_value: null
}
RefImpl {
__v_isShallow: false,
dep: undefined,
__v_isRef: true,
_rawValue: null,
_value: null
}
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:22 (4 by maintainers)
Top Results From Across the Web
Why useFetch is not working on page change in nuxt3 on ...
Docu: https://v3.nuxtjs.org/api/composables/use-fetch ... initialCache: false to useFetch to make sure the fetch run every time enter page.
Read more >`useFetch` data return null with mismatching client ... - GitHub
Initial load (server: false): fetch on mounted ... is not processed on my side... every usefetch falls to watch and onUnmount only.
Read more >How to Use Fetch with async/await - Dmitri Pavlutin
You'll understand how to fetch data, handle fetch errors, cancel a ... I was surprised that fetch() doesn't throw an error when the...
Read more >Data Fetching - Nuxt
Unlike fetch , this hook does not display a loading placeholder during ... to map the result of the server-side fetch() to the...
Read more >Client-side data fetching - Next.js
Unlike the server-side rendering APIs, you can use client-side data fetching at the component level. If done at the page level, the data...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I agree with @siddharth223437. The main issue for me is that the call is not blocked and the response never gets updated with the payload. So, the
await
is pointless. For me, the call is made to the backend but just doesn’t get blocked and then the only way to get the data is to watchdata
. This ends up behaving like useLazyFetch, which isn’t what is expected.Same problem when nuxt is set to
ssr: false
: await is not waiting foruseFetch()
to actually fetch the data.