Skip to content

Commit

Permalink
Merge pull request #201 from ripe-tech/ms/195-fix_sdk_nuxt_vercel
Browse files Browse the repository at this point in the history
#195: RIPE SDK compatibility with Nuxt.js under Vercel
  • Loading branch information
joamag authored Oct 9, 2020
2 parents fac48a9 + 83599f7 commit 59fc498
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/js/base/compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ if (
typeof XMLHttpRequest === "undefined" // eslint-disable-line no-use-before-define
) {
var XMLHttpRequest = null;
if (
if (typeof window !== "undefined" && typeof window.XMLHttpRequest !== "undefined") {
XMLHttpRequest = window.XMLHttpRequest;
} else if (
// eslint-disable-next-line camelcase
typeof __webpack_require__ === "undefined" &&
(typeof navigator === "undefined" || navigator.product !== "ReactNative")
Expand All @@ -71,8 +73,9 @@ if (
const mixedModuleName = "Xmlhttprequest";
const correctModuleName = mixedModuleName.toLowerCase();
XMLHttpRequest = require(correctModuleName).XMLHttpRequest;
} else {
XMLHttpRequest = window.XMLHttpRequest;
} else if (typeof __non_webpack_require__ !== "undefined") { // eslint-disable-line camelcase
// eslint-disable-next-line no-undef
XMLHttpRequest = __non_webpack_require__("xmlhttprequest").XMLHttpRequest;
}
}

Expand All @@ -85,14 +88,17 @@ if (
typeof fetch === "undefined" // eslint-disable-line no-use-before-define
) {
var fetch = null;
if (
if (typeof window !== "undefined" && typeof window.fetch !== "undefined") {
fetch = window.fetch;
} else if (
// eslint-disable-next-line camelcase
typeof __webpack_require__ === "undefined" &&
(typeof navigator === "undefined" || navigator.product !== "ReactNative")
) {
fetch = require("node-fetch");
} else {
fetch = window.fetch;
fetch = require("node-fetch").default;
} else if (typeof __non_webpack_require__ !== "undefined") { // eslint-disable-line camelcase
// eslint-disable-next-line no-undef
fetch = __non_webpack_require__("node-fetch").default;
}
}

Expand Down

0 comments on commit 59fc498

Please sign in to comment.