refreshNuxtData is used to refetch all or specific asyncData instances, including those from useAsyncData, useLazyAsyncData, useFetch, and useLazyFetch.
If your component is cached by
<KeepAlive> and enters a deactivated state, the asyncData inside the component will still be refetched until the component is unmounted.Type Signature
Parameters
A single string or an array of strings as keys that are used to fetch the data. When no keys are specified, all
useAsyncData and useFetch keys are re-fetched.Return Value
Returns a promise that resolves when all or specificasyncData instances have been refreshed.
Examples
Refresh All Data
This example refreshes all data being fetched usinguseAsyncData and useFetch in the Nuxt application:
Refresh Specific Data
This example refreshes only data where the key matchescount or user:
Notes
If you have access to the
asyncData instance, it is recommended to use its refresh or execute method as the preferred way to refetch the data.