diff --git a/docs/content/3.docs/1.usage/1.data-fetching.md b/docs/content/3.docs/1.usage/1.data-fetching.md index 6ac4d6f601..75236470c0 100644 --- a/docs/content/3.docs/1.usage/1.data-fetching.md +++ b/docs/content/3.docs/1.usage/1.data-fetching.md @@ -168,6 +168,39 @@ watch(posts, (newPosts) => { ``` +## `refreshNuxtData` + +Invalidate the cache of `useAsyncData`, `useLazyAsyncData`, `useFetch` and `useLazyFetch` and trigger the refetch. + +This method is useful if you want to refresh all the data fetching for a current page. + +### Usage + +```ts +refreshNuxtData(keys?: string | string[]) +``` + +Available options: + +* `keys`: Provides an array of keys that used in `useAsyncData` to refetch. When it's not specified, all `useAsyncData` and `useFetch` will be refetched. + +### Example + +```vue + + + +``` + ## Isomorphic fetch When we call `fetch` in the browser, user headers like `cookie` will be directly sent to the API. But during server-side-rendering, since the `fetch` request takes place 'internally' within the server, it doesn't include the user's browser cookies, nor does it pass on cookies from the fetch response. diff --git a/examples/use-async-data/app.vue b/examples/use-async-data/app.vue index fa1a0be39d..6cf95b41d6 100644 --- a/examples/use-async-data/app.vue +++ b/examples/use-async-data/app.vue @@ -1,18 +1,35 @@