Skip to content

Commit

Permalink
Merge pull request #86 from rudderlabs/develop
Browse files Browse the repository at this point in the history
remove browser check
  • Loading branch information
sayan-rudder authored Jun 25, 2020
2 parents ffaf74c + 3013ebc commit 3a793fe
Showing 1 changed file with 6 additions and 25 deletions.
31 changes: 6 additions & 25 deletions utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,6 @@ import logger from "./logUtil";
import { commonNames } from "../integrations/integration_cname";
import { clientToServerNames } from "../integrations/client_server_name";

let XMLHttpRequestNode;
if (!process.browser) {
XMLHttpRequestNode = require("Xmlhttprequest");
}

let btoaNode;
if (!process.browser) {
btoaNode = require("btoa");
}

/**
*
* Utility method for excluding null and empty values in JSON
Expand Down Expand Up @@ -77,11 +67,8 @@ function getCurrentTimeFormatted() {
function getJSON(url, wrappers, isLoaded, callback) {
// server-side integration, XHR is node module

if (process.browser) {
var xhr = new XMLHttpRequest();
} else {
var xhr = new XMLHttpRequestNode.XMLHttpRequest();
}
var xhr = new XMLHttpRequest();

xhr.open("GET", url, false);
xhr.onload = function () {
const { status } = xhr;
Expand All @@ -106,17 +93,11 @@ function getJSONTrimmed(context, url, writeKey, callback) {
// server-side integration, XHR is node module
const cb_ = callback.bind(context);

if (process.browser) {
var xhr = new XMLHttpRequest();
} else {
var xhr = new XMLHttpRequestNode.XMLHttpRequest();
}
var xhr = new XMLHttpRequest();

xhr.open("GET", url, true);
if (process.browser) {
xhr.setRequestHeader("Authorization", `Basic ${btoa(`${writeKey}:`)}`);
} else {
xhr.setRequestHeader("Authorization", `Basic ${btoaNode(`${writeKey}:`)}`);
}
xhr.setRequestHeader("Authorization", `Basic ${btoa(`${writeKey}:`)}`);


xhr.onload = function () {
const { status } = xhr;
Expand Down

0 comments on commit 3a793fe

Please sign in to comment.