fix(ui) - error handle
This commit is contained in:
parent
32d916314c
commit
e1580e20c3
1 changed files with 6 additions and 2 deletions
|
|
@ -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 || [] });
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue