diff options
| author | eugenijm <eugenijm@protonmail.com> | 2020-07-07 21:28:10 +0300 |
|---|---|---|
| committer | eugenijm <eugenijm@protonmail.com> | 2020-07-08 15:21:31 +0300 |
| commit | ed7310c04b3e36f1256db296784b6240023786a1 (patch) | |
| tree | befda02114e46a33d74ca38443c809db178ce755 /src/services/api | |
| parent | 18a1f5d62a72da45d62672043397a7471ab2c090 (diff) | |
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.
Diffstat (limited to 'src/services/api')
| -rw-r--r-- | src/services/api/api.service.js | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index 5428cc2a..40ea5bd9 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -122,18 +122,13 @@ const promisedRequest = ({ method, url, params, payload, credentials, headers = } return fetch(url, options) .then((response) => { - return new Promise((resolve, reject) => { - response.json() - .then((json) => { - if (!response.ok) { - return reject(new StatusCodeError(response.status, json, { url, options }, response)) - } - return resolve(json) - }) - .catch((error) => { - return reject(new StatusCodeError(response.status, error.message, { url, options }, response)) - }) - }) + return new Promise((resolve, reject) => response.json() + .then((json) => { + if (!response.ok) { + return reject(new StatusCodeError(response.status, json, { url, options }, response)) + } + return resolve(json) + })) }) } |
