@nuxt/docs-nightly 4.2.0-29331232.6f9cb0d2 → 4.2.0-29331654.df559ad9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -102,7 +102,6 @@ The `handler` function should be **side-effect free** to ensure predictable beha
|
|
|
102
102
|
- `dedupe`: avoid fetching same key more than once at a time (defaults to `cancel`). Possible options:
|
|
103
103
|
- `cancel` - cancels existing requests when a new one is made
|
|
104
104
|
- `defer` - does not make new requests at all if there is a pending request
|
|
105
|
-
- `timeout` - a number in milliseconds to wait before timing out the request (defaults to `undefined`, which means no timeout)
|
|
106
105
|
|
|
107
106
|
::note
|
|
108
107
|
Under the hood, `lazy: false` uses `<Suspense>` to block the loading of the route before the data has been fetched. Consider using `lazy: true` and implementing a loading state instead for a snappier user experience.
|
|
@@ -171,12 +170,12 @@ If you have not fetched data on the server (for example, with `server: false`),
|
|
|
171
170
|
|
|
172
171
|
```ts [Signature]
|
|
173
172
|
export function useAsyncData<DataT, DataE> (
|
|
174
|
-
handler: (nuxtApp
|
|
173
|
+
handler: (nuxtApp?: NuxtApp) => Promise<DataT>,
|
|
175
174
|
options?: AsyncDataOptions<DataT>
|
|
176
175
|
): AsyncData<DataT, DataE>
|
|
177
176
|
export function useAsyncData<DataT, DataE> (
|
|
178
177
|
key: MaybeRefOrGetter<string>,
|
|
179
|
-
handler: (nuxtApp
|
|
178
|
+
handler: (nuxtApp?: NuxtApp) => Promise<DataT>,
|
|
180
179
|
options?: AsyncDataOptions<DataT>
|
|
181
180
|
): Promise<AsyncData<DataT, DataE>>
|
|
182
181
|
|
|
@@ -191,7 +190,6 @@ type AsyncDataOptions<DataT> = {
|
|
|
191
190
|
pick?: string[]
|
|
192
191
|
watch?: MultiWatchSources | false
|
|
193
192
|
getCachedData?: (key: string, nuxtApp: NuxtApp, ctx: AsyncDataRequestContext) => DataT | undefined
|
|
194
|
-
timeout?: number
|
|
195
193
|
}
|
|
196
194
|
|
|
197
195
|
type AsyncDataRequestContext = {
|
|
@@ -210,8 +208,6 @@ type AsyncData<DataT, ErrorT> = {
|
|
|
210
208
|
|
|
211
209
|
interface AsyncDataExecuteOptions {
|
|
212
210
|
dedupe?: 'cancel' | 'defer'
|
|
213
|
-
timeout?: number
|
|
214
|
-
signal?: AbortSignal
|
|
215
211
|
}
|
|
216
212
|
|
|
217
213
|
type AsyncDataRequestStatus = 'idle' | 'pending' | 'success' | 'error'
|
|
@@ -145,7 +145,6 @@ type UseFetchOptions<DataT> = {
|
|
|
145
145
|
getCachedData?: (key: string, nuxtApp: NuxtApp, ctx: AsyncDataRequestContext) => DataT | undefined
|
|
146
146
|
deep?: boolean
|
|
147
147
|
dedupe?: 'cancel' | 'defer'
|
|
148
|
-
timeout?: number
|
|
149
148
|
default?: () => DataT
|
|
150
149
|
transform?: (input: DataT) => DataT | Promise<DataT>
|
|
151
150
|
pick?: string[]
|
|
@@ -170,8 +169,6 @@ type AsyncData<DataT, ErrorT> = {
|
|
|
170
169
|
|
|
171
170
|
interface AsyncDataExecuteOptions {
|
|
172
171
|
dedupe?: 'cancel' | 'defer'
|
|
173
|
-
timeout?: number
|
|
174
|
-
signal?: AbortSignal
|
|
175
172
|
}
|
|
176
173
|
|
|
177
174
|
type AsyncDataRequestStatus = 'idle' | 'pending' | 'success' | 'error'
|
|
@@ -198,7 +195,6 @@ type AsyncDataRequestStatus = 'idle' | 'pending' | 'success' | 'error'
|
|
|
198
195
|
| `lazy` | `boolean` | `false` | If true, resolves after route loads (does not block navigation). |
|
|
199
196
|
| `immediate` | `boolean` | `true` | If false, prevents request from firing immediately. |
|
|
200
197
|
| `default` | `() => DataT` | - | Factory for default value of `data` before async resolves. |
|
|
201
|
-
| `timeout` | `number` | - | A number in milliseconds to wait before timing out the request (defaults to `undefined`, which means no timeout) |
|
|
202
198
|
| `transform` | `(input: DataT) => DataT \| Promise<DataT>` | - | Function to transform the result after resolving. |
|
|
203
199
|
| `getCachedData`| `(key, nuxtApp, ctx) => DataT \| undefined` | - | Function to return cached data. See below for default. |
|
|
204
200
|
| `pick` | `string[]` | - | Only pick specified keys from the result. |
|