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:
parent
b95d53791c
commit
0873e77ff4
5 changed files with 20 additions and 19 deletions
|
@ -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 };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue