Skip to content

Commit 0813f5b

Browse files
author
Crhistian Ramirez
committed
fix: incorrectly trying to use node-only functionality in the browser #44
1 parent 348af1b commit 0813f5b

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/Sdk.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,11 @@
373373
var _this = this;
374374
var url = this.buildUrl(path, pathParams);
375375
var request = superagent(httpMethod, url);
376-
request.parse(customJsonParser);
377-
request.buffer(true)
376+
if(typeof process === 'object' && process + '' === '[object process]') {
377+
// only use custom parser in node
378+
request.parse(customJsonParser);
379+
request.buffer(true)
380+
}
378381

379382
// apply authentications
380383
this.applyAuthToRequest(request, accessToken);
@@ -446,8 +449,11 @@ exports.prototype.callAuth = function callApi(path, httpMethod, pathParams,
446449
var _this = this;
447450
var url = _this.baseAuthPath.replace(/\/+$/, '') + path;
448451
var request = superagent(httpMethod, url);
449-
request.parse(customJsonParser);
450-
request.buffer(true)
452+
if(typeof process === 'object' && process + '' === '[object process]') {
453+
// only use custom parser in node
454+
request.parse(customJsonParser);
455+
request.buffer(true)
456+
}
451457

452458
// set query parameters
453459
request.query(this.normalizeParams(queryParams));

0 commit comments

Comments
 (0)