@@ -12,17 +12,7 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary {
1212 public maxRetries!: number ;
1313 public backoffBase!: number ;
1414 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;
2616
2717 public send(request: RequestContext): Promise<ResponseContext > {
2818 if (this.debug) {
@@ -79,7 +69,14 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary {
7969 signal: request.getHttpConfig().signal,
8070 }
8171 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);
8380 const responseHeaders: { [name: string]: string } = {};
8481 resp.headers.forEach((value: string, name: string) => {
8582 responseHeaders[name] = value;
0 commit comments