1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 12:56:41 +07:00

fixed error handling

This commit is contained in:
Fedor Katurov 2021-03-04 13:57:00 +07:00
parent b95d53791c
commit 0873e77ff4
5 changed files with 20 additions and 19 deletions

View file

@ -131,15 +131,12 @@ export function configureStore(): {
});
// Logout on 401
api.interceptors.response.use(undefined, (error: AxiosError<{ message: string }>) => {
api.interceptors.response.use(undefined, (error: AxiosError<{ error: string }>) => {
if (error.response?.status === 401) {
store.dispatch(authLogout());
}
console.log('Вот что случилось на сервере:', error);
throw new Error(
error?.response?.data?.message || error?.message || error?.response?.statusText
);
throw new Error(error?.response?.data?.error || error?.message || error?.response?.statusText);
});
return { store, persistor };