From 10922d7a4eb6376ef62217847c46bf52480f5e97 Mon Sep 17 00:00:00 2001 From: bblake Date: Sun, 18 Sep 2022 08:30:47 -0500 Subject: [PATCH] rejecting response when json --- request/request.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/request/request.js b/request/request.js index 94053650e..0bf7a5b1d 100644 --- a/request/request.js +++ b/request/request.js @@ -93,13 +93,17 @@ module.exports = function($window, oncompletion) { resolve(response) } else { - var completeErrorResponse = function() { - try { message = ev.target.responseText } - catch (e) { message = JSON.stringify(response) } - var error = new Error(message) - error.code = ev.target.status - error.response = response - reject(error) + var completeErrorResponse = function () { + if (ev.target.responseType == "json") { + reject(response) + } else { + try { message = ev.target.responseText } + catch (e) { message = response } + var error = new Error(message) + error.code = ev.target.status + error.response = response + reject(error) + } } if (xhr.status === 0) {