Skip to content

Commit

Permalink
rejecting response when json
Browse files Browse the repository at this point in the history
  • Loading branch information
ebsi-bblake committed Sep 18, 2022
1 parent 6edfeb7 commit 10922d7
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions request/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 10922d7

Please sign in to comment.