feat(ui): added new auth guard with react-query and axios

This commit is contained in:
akhilmhdh
2023-01-26 00:14:01 +05:30
parent a6f480d3f8
commit a6387e7552
16 changed files with 234 additions and 30 deletions
+19
View File
@@ -0,0 +1,19 @@
import axios from 'axios';
import { getAuthToken } from '@app/reactQuery';
export const apiRequest = axios.create({
baseURL: '/',
headers: {
'Content-Type': 'application/json'
}
});
apiRequest.interceptors.request.use((config) => {
const token = getAuthToken();
if (token && config.headers) {
// eslint-disable-next-line no-param-reassign
config.headers.Authorization = `Bearer ${token}`;
}
return config;
});