re-structure to monorepo.

This commit is contained in:
a.bouhuolia
2023-02-03 01:02:31 +02:00
parent 8242ec64ba
commit 7a0a13f9d5
10400 changed files with 46966 additions and 17223 deletions

View File

@@ -0,0 +1,41 @@
// @ts-nocheck
import axios from 'axios';
import { store } from '@/store/createStore';
const http = axios.create();
http.interceptors.request.use((request) => {
const state = store.getState();
const { token, organization } = state.authentication;
const locale = 'en';
if (token) {
request.headers.common['x-access-token'] = token;
}
if (organization) {
request.headers.common['organization-id'] = organization;
}
if (locale) {
request.headers.common['Accept-Language'] = locale;
}
request.headers.common['Accept-Language'] = 'ar';
return request;
}, (error) => {
return Promise.reject(error);
});
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());
// }
return Promise.reject(error);
});
export default http;