diff --git a/frontend/app/api_middleware.js b/frontend/app/api_middleware.js index 8f9965ec5..783ebe8c3 100644 --- a/frontend/app/api_middleware.js +++ b/frontend/app/api_middleware.js @@ -12,10 +12,14 @@ export default store => next => (action) => { const client = new APIClient(); return call(client) - .then(response => { + .then(async response => { if (response.status === 403) { next({ type: DELETE }); } + if (!response.ok) { + const text = await response.text() + return Promise.reject(text); + } return response.json() }) .then(json => json || {}) // TEMP TODO on server: no empty responces @@ -31,7 +35,7 @@ export default store => next => (action) => { }) .catch((e) => { logger.error("Error during API request. ", e) - return next({ type: FAILURE, errors: [ "Connection error", String(e) ] }); + return next({ type: FAILURE, errors: JSON.parse(e).errors || [] }); }); };