Skip to content

Commit

Permalink
chore: add fetch only for browser
Browse files Browse the repository at this point in the history
  • Loading branch information
andriyl committed Apr 7, 2021
1 parent 0acef35 commit a70f9f1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/utils/loadAndBundleSpec.ts
Original file line number Diff line number Diff line change
@@ -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<OpenAPISpec> {
const rawConfig: RawConfig = {};
const config = new Config(rawConfig);
const config = new Config({});
const bundleOpts = {
config,
base: IS_BROWSER ? window.location.href : process.cwd()
Expand All @@ -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;
}

Expand Down

0 comments on commit a70f9f1

Please sign in to comment.