1
0
mirror of https://github.com/sasjs/adapter.git synced 2025-12-11 09:24:35 +00:00

fix(*): use fetch polyfill in IE and Edge

This commit is contained in:
Krishna Acondy
2020-08-13 20:53:27 +01:00
parent b4c7868fb6
commit 0ffa62fab4
2 changed files with 33 additions and 3 deletions

View File

@@ -1,6 +1,10 @@
import "isomorphic-fetch";
import * as e6p from "es6-promise";
(e6p as any).polyfill();
if (isIEorEDGE()) {
window.fetch = undefined as any; // ensure the polyfill runs
}
// tslint:disable-next-line
require("isomorphic-fetch");
import {
convertToCSV,
compareTimestamps,
@@ -27,6 +31,7 @@ import {
import { SASViyaApiClient } from "./SASViyaApiClient";
import { SAS9ApiClient } from "./SAS9ApiClient";
import { FileUploader } from "./FileUploader";
import { isIEorEDGE } from "./utils/isIeOrEdge";
const defaultConfig: SASjsConfig = {
serverUrl: "",
@@ -654,9 +659,11 @@ export default class SASjs {
try {
responseJson = JSON.parse(response!.result);
} catch {
responseJson = JSON.parse(parseWeboutResponse(response!.result));
responseJson = JSON.parse(
parseWeboutResponse(response!.result)
);
}
return responseJson;
})
.catch(async (e) => {

23
src/utils/isIeOrEdge.ts Normal file
View File

@@ -0,0 +1,23 @@
export function isIEorEDGE() {
const ua = window.navigator.userAgent;
const msie = ua.indexOf("MSIE ");
if (msie > 0) {
// IE 10 or older => return version number
return true;
}
const trident = ua.indexOf("Trident/");
if (trident > 0) {
return true;
}
const edge = ua.indexOf("Edge/");
if (edge > 0) {
// Edge (IE 12+) => return version number
return true;
}
// other browser
return false;
}