question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

on initial client side load with `server: false`, useFetch does not await data fetching

See original GitHub issue

Environment

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:open
  • Created a year ago
  • Reactions:3
  • Comments:22 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
bbrncommented, Apr 23, 2022

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 watch data. This ends up behaving like useLazyFetch, which isn’t what is expected.

2reactions
mario-neuholdcommented, May 3, 2022

Same problem when nuxt is set to ssr: false: await is not waiting for useFetch() to actually fetch the data.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found