Skip to content

Commit db9a3ec

Browse files
committed
added check for property json on resp obj
1 parent 0e7cb84 commit db9a3ec

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/OAuthClient.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,10 @@ OAuthClient.prototype.createToken = function createToken(uri) {
182182
resolve(this.getTokenRequest(request));
183183
})
184184
.then((res) => {
185-
const authResponse = res.json ? res : null;
185+
const authResponse = res.hasOwnProperty('json')? res : null;
186186
const json = (authResponse && authResponse.json) || res;
187187
this.token.setToken(json);
188-
this.log('info', 'Create Token response is : ', JSON.stringify(authResponse && authResponse.json, null, 2));
188+
this.log('info', 'Create Token response is : ', JSON.stringify(authResponse && authResponse.json, null, 2));
189189
return authResponse;
190190
})
191191
.catch((e) => {
@@ -223,7 +223,7 @@ OAuthClient.prototype.refresh = function refresh() {
223223
resolve(this.getTokenRequest(request));
224224
})
225225
.then((res) => {
226-
const authResponse = res.json ? res : null;
226+
const authResponse = res.hasOwnProperty('json')? res : null;
227227
const json = (authResponse && authResponse.json) || res;
228228
this.token.setToken(json);
229229
this.log('info', 'Refresh Token () response is : ', JSON.stringify(authResponse && authResponse.json, null, 2));
@@ -265,7 +265,7 @@ OAuthClient.prototype.refreshUsingToken = function refreshUsingToken(refresh_tok
265265
resolve(this.getTokenRequest(request));
266266
})
267267
.then((res) => {
268-
const authResponse = res.json ? res : null;
268+
const authResponse = res.hasOwnProperty('json')? res : null;
269269
const json = (authResponse && authResponse.json) || res;
270270
this.token.setToken(json);
271271
this.log(
@@ -315,7 +315,7 @@ OAuthClient.prototype.revoke = function revoke(params) {
315315
resolve(this.getTokenRequest(request));
316316
})
317317
.then((res) => {
318-
const authResponse = res.json ? res : null;
318+
const authResponse = res.hasOwnProperty('json')? res : null;
319319
this.token.clearToken();
320320
this.log('info', 'Revoke Token () response is : ', JSON.stringify(authResponse && authResponse.json, null, 2));
321321
return authResponse;
@@ -349,7 +349,7 @@ OAuthClient.prototype.getUserInfo = function getUserInfo() {
349349
resolve(this.getTokenRequest(request));
350350
})
351351
.then((res) => {
352-
const authResponse = res.json ? res : null;
352+
const authResponse = res.hasOwnProperty('json')? res : null;
353353
this.log(
354354
'info',
355355
'The Get User Info () response is : ', JSON.stringify(authResponse && authResponse.json, null, 2),

0 commit comments

Comments
 (0)