Skip to content

Commit e34e246

Browse files
Added FETCH_IMPL to config
1 parent e95dae3 commit e34e246

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

src/templates/core/OpenAPI.hbs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export type OpenAPIConfig = {
1515
PASSWORD?: string | Resolver<string>;
1616
HEADERS?: Headers | Resolver<Headers>;
1717
ENCODE_PATH?: (path: string) => string;
18+
FETCH_IMPL?: any;
1819
};
1920

2021
export const OpenAPI: OpenAPIConfig = {
@@ -27,4 +28,5 @@ export const OpenAPI: OpenAPIConfig = {
2728
PASSWORD: undefined,
2829
HEADERS: undefined,
2930
ENCODE_PATH: undefined,
31+
FETCH_IMPL: undefined,
3032
};
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
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
99
): Promise<Response> => {
1010
const controller = new AbortController();
1111

1212
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,
1717
};
1818

1919
if (config.WITH_CREDENTIALS) {
20-
request.credentials = config.CREDENTIALS;
20+
request.credentials = config.CREDENTIALS;
2121
}
2222

2323
onCancel(() => controller.abort());
2424

25-
return await fetch(url, request);
26-
};
25+
return await (config.FETCH_IMPL ?? fetch)(url, request);
26+
};

0 commit comments

Comments
 (0)