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.

Allow preventing `useFetch`/`useAsyncData` from firing immediately

See original GitHub issue

Environment

n/a

Reproduction

n/a

Describe the bug

In my use case I’d find it particularily useful to prevent the useFetch/useAsyncData from firing immediately, as it has been implemented in the useFetch from VueUse:

https://vueuse.org/core/usefetch/#prevent-request-from-firing-immediately

… e.g. I’d still want to declare/prepare the call in the top level, but in scenarios when there is no logged in user and the request is only for the authorized ones, I can save the client from making an unnecessary request without having to wrap the call in a conditional statement.

Additional context

No response

Logs

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
pi0commented, Sep 7, 2022

More thinking, if purpose is really the refrashable behavior of asyncData having an option wouldn’t be a bad start at the end (otherwise we will end of with dosens of aliases).

1reaction
TheDutchCodercommented, Aug 28, 2022

I think this is quite an essential feature to have, because currently you can’t call data “on demand”.

For example: saving data when clicking a “save” button. You can’t actually do a post on demand currently with any of the composables.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why useFetch is not working on page change in nuxt3 on ...
useFetch tries to cache the document for you and reuses the cache ... To avoid that behavior you can pass a function instead...
Read more >
useAsyncData · Nuxt Composables
useAsyncData provides access to data that resolves asynchronously. ... immediate: When set to false , will prevent the request from firing immediately.
Read more >
useFetch
If the last argument of useFetch is not a dependency array [] , then it will not fire until you call one of...
Read more >
Usefetch nuxt3 - optic palace
Nuxt 3 ではそれらが新たにuseFetch () とuseAsyncData () のふたつにアップデート ... fetch that allows server-side and client-side asynchronous data-fetching.
Read more >
Data Fetching - Nuxt
This allows your page to render with all of its required data present. ... To avoid cache conflicts, it may be necessary to...
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