docs: update getCachedData types (#31208)

This commit is contained in:
xjccc 2025-03-05 16:20:11 +08:00 committed by Daniel Roe
parent 16e09391b9
commit 4d258e2b10
No known key found for this signature in database
GPG Key ID: 3714AB03996F442B
2 changed files with 4 additions and 4 deletions

View File

@ -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<DataT> = {
transform?: (input: DataT) => DataT | Promise<DataT>
pick?: string[]
watch?: WatchSource[]
getCachedData?: (key: string, nuxtApp: NuxtApp) => DataT
getCachedData?: (key: string, nuxtApp: NuxtApp) => DataT | undefined
}
type AsyncData<DataT, ErrorT> = {

View File

@ -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<DataT> = {
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