diff --git a/docs/3.api/2.composables/use-async-data.md b/docs/3.api/2.composables/use-async-data.md index 0aba9217e8..b0d88b8ea9 100644 --- a/docs/3.api/2.composables/use-async-data.md +++ b/docs/3.api/2.composables/use-async-data.md @@ -74,7 +74,7 @@ The `handler` function should be **side-effect free** to ensure predictable beha - `transform`: a function that can be used to alter `handler` function result after resolving - `getCachedData`: Provide a function which returns cached data. A `null` or `undefined` return value will trigger a fetch. By default, this is: ```ts - const getDefaultCachedData = (key) => nuxtApp.isHydrating + const getDefaultCachedData = (key, nuxtApp) => nuxtApp.isHydrating ? nuxtApp.payload.data[key] : nuxtApp.static.data[key] ``` @@ -141,7 +141,7 @@ type AsyncDataOptions = { transform?: (input: DataT) => DataT | Promise pick?: string[] watch?: WatchSource[] - getCachedData?: (key: string, nuxtApp: NuxtApp) => DataT + getCachedData?: (key: string, nuxtApp: NuxtApp) => DataT | undefined } type AsyncData = { diff --git a/docs/3.api/2.composables/use-fetch.md b/docs/3.api/2.composables/use-fetch.md index 42e1119b6e..d733546ba1 100644 --- a/docs/3.api/2.composables/use-fetch.md +++ b/docs/3.api/2.composables/use-fetch.md @@ -111,7 +111,7 @@ All fetch options can be given a `computed` or `ref` value. These will be watche - `transform`: a function that can be used to alter `handler` function result after resolving - `getCachedData`: Provide a function which returns cached data. A `null` or `undefined` return value will trigger a fetch. By default, this is: ```ts - const getDefaultCachedData = (key) => nuxtApp.isHydrating + const getDefaultCachedData = (key, nuxtApp) => nuxtApp.isHydrating ? nuxtApp.payload.data[key] : nuxtApp.static.data[key] ``` @@ -174,7 +174,7 @@ type UseFetchOptions = { server?: boolean lazy?: boolean immediate?: boolean - getCachedData?: (key: string, nuxtApp: NuxtApp) => DataT + getCachedData?: (key: string, nuxtApp: NuxtApp) => DataT | undefined deep?: boolean dedupe?: 'cancel' | 'defer' default?: () => DataT