From ed7310c04b3e36f1256db296784b6240023786a1 Mon Sep 17 00:00:00 2001 From: eugenijm Date: Tue, 7 Jul 2020 21:28:10 +0300 Subject: [PATCH] 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. --- src/services/api/api.service.js | 19 +++++++------------ 1 file 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) + })) }) }