@@ -20,14 +20,24 @@ export type ResponseStyle = 'data' | 'fields';
20
20
export interface Config < T extends ClientOptions = ClientOptions >
21
21
extends Omit < RequestInit , 'body' | 'headers' | 'method' > ,
22
22
CoreConfig {
23
+ /**
24
+ * HTTP(S) agent configuration (Node.js only). Passed through to ofetch.
25
+ */
23
26
agent ?: OfetchOptions [ 'agent' ] ;
24
27
/**
25
28
* Base URL for all requests made by this client.
26
29
*/
27
30
baseUrl ?: T [ 'baseUrl' ] ;
28
- /** Node-only proxy/agent options */
31
+ /**
32
+ * Node-only proxy/agent options.
33
+ */
29
34
dispatcher ?: OfetchOptions [ 'dispatcher' ] ;
30
- /** Optional fetch instance used for SSE streaming */
35
+ /**
36
+ * Fetch API implementation. Used for SSE streaming. You can use this option
37
+ * to provide a custom fetch instance.
38
+ *
39
+ * @default globalThis.fetch
40
+ */
31
41
fetch ?: typeof fetch ;
32
42
// No custom fetch option: provide custom instance via `ofetch` instead
33
43
/**
@@ -42,10 +52,23 @@ export interface Config<T extends ClientOptions = ClientOptions>
42
52
* be used for requests instead of the default `ofetch` export.
43
53
*/
44
54
ofetch ?: typeof ofetch ;
45
- /** ofetch interceptors and runtime options */
55
+ /**
56
+ * ofetch hook called before a request is sent.
57
+ */
46
58
onRequest ?: OfetchOptions [ 'onRequest' ] ;
59
+ /**
60
+ * ofetch hook called when a request fails before receiving a response
61
+ * (e.g., network errors or aborted requests).
62
+ */
47
63
onRequestError ?: OfetchOptions [ 'onRequestError' ] ;
64
+ /**
65
+ * ofetch hook called after a successful response is received and parsed.
66
+ */
48
67
onResponse ?: OfetchOptions [ 'onResponse' ] ;
68
+ /**
69
+ * ofetch hook called when the response indicates an error (non-ok status)
70
+ * or when response parsing fails.
71
+ */
49
72
onResponseError ?: OfetchOptions [ 'onResponseError' ] ;
50
73
/**
51
74
* Return the response data parsed in a specified format. By default, `auto`
@@ -80,7 +103,13 @@ export interface Config<T extends ClientOptions = ClientOptions>
80
103
* Automatically retry failed requests.
81
104
*/
82
105
retry ?: OfetchOptions [ 'retry' ] ;
106
+ /**
107
+ * Delay (in ms) between retry attempts.
108
+ */
83
109
retryDelay ?: OfetchOptions [ 'retryDelay' ] ;
110
+ /**
111
+ * HTTP status codes that should trigger a retry.
112
+ */
84
113
retryStatusCodes ?: OfetchOptions [ 'retryStatusCodes' ] ;
85
114
/**
86
115
* Throw an error instead of returning it in the response?
0 commit comments