Undo the promise rejection on the json parser error in promisedRequest

to keep the existing behavior in case some parts of the code rely on it
and to limit the overall scope of the changes.
This commit is contained in:
eugenijm 2020-07-07 21:28:10 +03:00
parent 18a1f5d62a
commit ed7310c04b

View file

@ -122,18 +122,13 @@ const promisedRequest = ({ method, url, params, payload, credentials, headers =
} }
return fetch(url, options) return fetch(url, options)
.then((response) => { .then((response) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => response.json()
response.json() .then((json) => {
.then((json) => { if (!response.ok) {
if (!response.ok) { return reject(new StatusCodeError(response.status, json, { url, options }, response))
return reject(new StatusCodeError(response.status, json, { url, options }, response)) }
} return resolve(json)
return resolve(json) }))
})
.catch((error) => {
return reject(new StatusCodeError(response.status, error.message, { url, options }, response))
})
})
}) })
} }