Allow preventing `useFetch`/`useAsyncData` from firing immediately
See original GitHub issueEnvironment
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:
- Created a year ago
- Comments:5 (2 by maintainers)
Top 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 >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
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).
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.