refactoring: authentication with react-query.

This commit is contained in:
a.bouhuolia
2021-02-20 15:33:20 +02:00
parent 8f680e2068
commit a079f711d4
57 changed files with 1629 additions and 1290 deletions

View File

@@ -1,7 +1,5 @@
import axios from 'axios';
import { store } from 'store/createStore';
import { logout } from 'store/authentication/authentication.actions';
import { setGlobalErrors } from 'store/globalErrors/globalErrors.actions';
const http = axios.create();
@@ -27,13 +25,13 @@ http.interceptors.request.use((request) => {
http.interceptors.response.use((response) => response, (error) => {
const { status } = error.response;
if (status >= 500) {
store.dispatch(setGlobalErrors({ something_wrong: true }));
}
if (status === 401) {
store.dispatch(setGlobalErrors({ session_expired: true }));
store.dispatch(logout());
}
// if (status >= 500) {
// store.dispatch(setGlobalErrors({ something_wrong: true }));
// }
// if (status === 401) {
// // store.dispatch(setGlobalErrors({ session_expired: true }));
// // store.dispatch(logout());
// }
return Promise.reject(error);
});