File tree Expand file tree Collapse file tree 2 files changed +16
-14
lines changed Expand file tree Collapse file tree 2 files changed +16
-14
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ export type OpenAPIConfig = {
15
15
PASSWORD?: string | Resolver<string >;
16
16
HEADERS?: Headers | Resolver<Headers >;
17
17
ENCODE_PATH?: (path: string) => string;
18
+ FETCH_IMPL?: any;
18
19
};
19
20
20
21
export const OpenAPI: OpenAPIConfig = {
@@ -27,4 +28,5 @@ export const OpenAPI: OpenAPIConfig = {
27
28
PASSWORD: undefined,
28
29
HEADERS: undefined,
29
30
ENCODE_PATH: undefined,
31
+ FETCH_IMPL: undefined,
30
32
};
Original file line number Diff line number Diff line change 1
1
export const sendRequest = async (
2
- config: OpenAPIConfig,
3
- options: ApiRequestOptions,
4
- url: string,
5
- body: any,
6
- formData: FormData | undefined,
7
- headers: Headers,
8
- onCancel: OnCancel
2
+ config: OpenAPIConfig,
3
+ options: ApiRequestOptions,
4
+ url: string,
5
+ body: any,
6
+ formData: FormData | undefined,
7
+ headers: Headers,
8
+ onCancel: OnCancel
9
9
): Promise<Response > => {
10
10
const controller = new AbortController();
11
11
12
12
const request: RequestInit = {
13
- headers,
14
- body: body ?? formData,
15
- method: options.method,
16
- signal: controller.signal,
13
+ headers,
14
+ body: body ?? formData,
15
+ method: options.method,
16
+ signal: controller.signal,
17
17
};
18
18
19
19
if (config.WITH_CREDENTIALS) {
20
- request.credentials = config.CREDENTIALS;
20
+ request.credentials = config.CREDENTIALS;
21
21
}
22
22
23
23
onCancel(() => controller.abort());
24
24
25
- return await fetch(url, request);
26
- };
25
+ return await (config.FETCH_IMPL ?? fetch) (url, request);
26
+ };
You can’t perform that action at this time.
0 commit comments