@@ -12,17 +12,7 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary {
12
12
public maxRetries!: number ;
13
13
public backoffBase!: number ;
14
14
public backoffMultiplier!: number;
15
- #fetch: any;
16
-
17
- constructor({ fetch: customFetch }: { fetch?: any }) {
18
- this.#fetch =
19
- customFetch ||
20
- // On non-node environments, use native fetch if available.
21
- // `cross-fetch` incorrectly assumes all browsers have XHR available.
22
- // See https://github.com/lquixada/cross-fetch/issues/78
23
- // TODO: Remove once once above issue is resolved.
24
- (!isNode && typeof fetch === "function" ? fetch : crossFetch);
25
- }
15
+ public fetch: any;
26
16
27
17
public send(request: RequestContext): Promise<ResponseContext > {
28
18
if (this.debug) {
@@ -79,7 +69,14 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary {
79
69
signal: request.getHttpConfig().signal,
80
70
}
81
71
try {
82
- const resp = await this.#fetch(request.getUrl(),fetchOptions);
72
+ const fetchFunction = this.fetch ||
73
+ // On non-node environments, use native fetch if available.
74
+ // `cross-fetch` incorrectly assumes all browsers have XHR available.
75
+ // See https://github.com/lquixada/cross-fetch/issues/78
76
+ // TODO: Remove once once above issue is resolved.
77
+ ((!isNode && typeof fetch === "function") ? fetch : crossFetch);
78
+
79
+ const resp = await fetchFunction(request.getUrl(),fetchOptions);
83
80
const responseHeaders: { [name: string]: string } = {};
84
81
resp.headers.forEach((value: string, name: string) => {
85
82
responseHeaders[name] = value;
0 commit comments