Skip to content

Commit bcdc5af

Browse files
chore: add docs to RequestOptions type
1 parent d9e2f49 commit bcdc5af

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

src/client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ export interface ClientOptions {
7878
*
7979
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
8080
* much longer than this timeout before the promise succeeds or fails.
81+
*
82+
* @unit milliseconds
8183
*/
8284
timeout?: number | undefined;
8385
/**

src/internal/request-options.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,70 @@ import { type HeadersLike } from './headers';
99
export type FinalRequestOptions = RequestOptions & { method: HTTPMethod; path: string };
1010

1111
export type RequestOptions = {
12+
/**
13+
* The HTTP method for the request (e.g., 'get', 'post', 'put', 'delete').
14+
*/
1215
method?: HTTPMethod;
16+
17+
/**
18+
* The URL path for the request.
19+
*
20+
* @example "/v1/foo"
21+
*/
1322
path?: string;
23+
24+
/**
25+
* Query parameters to include in the request URL.
26+
*/
1427
query?: object | undefined | null;
28+
29+
/**
30+
* The request body. Can be a string, JSON object, FormData, or other supported types.
31+
*/
1532
body?: unknown;
33+
34+
/**
35+
* HTTP headers to include with the request. Can be a Headers object, plain object, or array of tuples.
36+
*/
1637
headers?: HeadersLike;
38+
39+
/**
40+
* The maximum number of times that the client will retry a request in case of a
41+
* temporary failure, like a network error or a 5XX error from the server.
42+
*
43+
* @default 2
44+
*/
1745
maxRetries?: number;
46+
1847
stream?: boolean | undefined;
48+
49+
/**
50+
* The maximum amount of time (in milliseconds) that the client should wait for a response
51+
* from the server before timing out a single request.
52+
*
53+
* @unit milliseconds
54+
*/
1955
timeout?: number;
56+
57+
/**
58+
* Additional `RequestInit` options to be passed to the underlying `fetch` call.
59+
* These options will be merged with the client's default fetch options.
60+
*/
2061
fetchOptions?: MergedRequestInit;
62+
63+
/**
64+
* An AbortSignal that can be used to cancel the request.
65+
*/
2166
signal?: AbortSignal | undefined | null;
67+
68+
/**
69+
* A unique key for this request to enable idempotency.
70+
*/
2271
idempotencyKey?: string;
72+
73+
/**
74+
* Override the default base URL for this specific request.
75+
*/
2376
defaultBaseURL?: string | undefined;
2477

2578
__binaryResponse?: boolean | undefined;

0 commit comments

Comments
 (0)