From a70f9f13dc1999cedc52e5cfce325388169fa435 Mon Sep 17 00:00:00 2001 From: Andriy Leliv Date: Wed, 7 Apr 2021 19:45:51 +0300 Subject: [PATCH] chore: add fetch only for browser --- src/utils/loadAndBundleSpec.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/utils/loadAndBundleSpec.ts b/src/utils/loadAndBundleSpec.ts index db8c4912..1a29b673 100644 --- a/src/utils/loadAndBundleSpec.ts +++ b/src/utils/loadAndBundleSpec.ts @@ -1,12 +1,11 @@ /* tslint:disable-next-line:no-implicit-dependencies */ import { convertObj } from 'swagger2openapi'; import { OpenAPISpec } from '../types'; -import { Source, Document, bundle, Config, RawConfig } from '@redocly/openapi-core'; +import { Source, Document, bundle, Config } from '@redocly/openapi-core'; import { IS_BROWSER } from './dom'; export async function loadAndBundleSpec(specUrlOrObject: object | string): Promise { - const rawConfig: RawConfig = {}; - const config = new Config(rawConfig); + const config = new Config({}); const bundleOpts = { config, base: IS_BROWSER ? window.location.href : process.cwd() @@ -18,7 +17,9 @@ export async function loadAndBundleSpec(specUrlOrObject: object | string): Promi parsed: specUrlOrObject } as Document } else { - config.resolve.http.customFetch = fetch; + if (IS_BROWSER) { + config.resolve.http.customFetch = global.fetch; + } bundleOpts['ref'] = specUrlOrObject; }