fix(ui) - check for error status and force logout (#1179)

* fix(ui) - token expire

* fix(ui) - token expire
This commit is contained in:
Shekar Siri 2023-04-18 13:08:18 +02:00 committed by GitHub
parent c0e9205780
commit d406c720b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -13,9 +13,9 @@ export default () => (next) => (action) => {
return call(client)
.then(async (response) => {
if (response.status === 403) {
next({ type: FETCH_ACCOUNT.FAILURE });
}
// if (response.status === 403) {
// next({ type: FETCH_ACCOUNT.FAILURE });
// }
if (!response.ok) {
const text = await response.text();
return Promise.reject(text);
@ -34,6 +34,10 @@ export default () => (next) => (action) => {
}
})
.catch(async (e) => {
if (e.response?.status === 403) {
next({ type: FETCH_ACCOUNT.FAILURE });
}
const data = await e.response?.json();
logger.error('Error during API request. ', e);
return next({ type: FAILURE, errors: data ? parseError(data.errors) : [] });