From 6edfeb70f27296aab9b94d98c8a03bb7bc6cb1d3 Mon Sep 17 00:00:00 2001 From: bblake Date: Sun, 18 Sep 2022 07:35:57 -0500 Subject: [PATCH 1/2] stringifying response Bumps [terser](https://github.com/terser/terser) from 4.3.4 to 4.8.1. - [Release notes](https://github.com/terser/terser/releases) - [Changelog](https://github.com/terser/terser/blob/master/CHANGELOG.md) - [Commits](https://github.com/terser/terser/commits) --- updated-dependencies: - dependency-name: terser dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- request/request.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/request/request.js b/request/request.js index 7252ccade..94053650e 100644 --- a/request/request.js +++ b/request/request.js @@ -95,7 +95,7 @@ module.exports = function($window, oncompletion) { else { var completeErrorResponse = function() { try { message = ev.target.responseText } - catch (e) { message = response } + catch (e) { message = JSON.stringify(response) } var error = new Error(message) error.code = ev.target.status error.response = response From 10922d7a4eb6376ef62217847c46bf52480f5e97 Mon Sep 17 00:00:00 2001 From: bblake Date: Sun, 18 Sep 2022 08:30:47 -0500 Subject: [PATCH 2/2] 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) {