From 8192f69f67a4f31b10050dcd66f924c62f1d693b Mon Sep 17 00:00:00 2001 From: Krishna Acondy Date: Tue, 18 Aug 2020 08:25:40 +0100 Subject: [PATCH] fix(*): do not use polyfill when running on Node.js --- src/SASjs.ts | 4 +++- src/utils/isIeOrEdge.ts | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/SASjs.ts b/src/SASjs.ts index 9167280..583e78c 100644 --- a/src/SASjs.ts +++ b/src/SASjs.ts @@ -2,7 +2,9 @@ import { isIEorEdgeOrOldFirefox } from "./utils/isIeOrEdge"; import * as e6p from "es6-promise"; (e6p as any).polyfill(); if (isIEorEdgeOrOldFirefox()) { - window.fetch = undefined as any; // ensure the polyfill runs + if (window) { + window.fetch = undefined as any; // ensure the polyfill runs + } } // tslint:disable-next-line require("isomorphic-fetch"); diff --git a/src/utils/isIeOrEdge.ts b/src/utils/isIeOrEdge.ts index 59400da..2a57ac3 100644 --- a/src/utils/isIeOrEdge.ts +++ b/src/utils/isIeOrEdge.ts @@ -1,4 +1,7 @@ export function isIEorEdgeOrOldFirefox() { + if (typeof window === "undefined") { + return false; + } const ua = window.navigator.userAgent; if (ua.indexOf("Firefox") > 0) {