setup husky prettier eslint
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { ENV_CONSTANT } from "@/constants/secrect.constant";
|
||||
import axios from "axios";
|
||||
import { ENV_CONSTANT } from '@/constants/secrect.constant';
|
||||
import axios from 'axios';
|
||||
|
||||
const BASE_URL = ENV_CONSTANT.BASE_API_URL;
|
||||
|
||||
@@ -7,24 +7,24 @@ const axiosClient = axios.create({
|
||||
baseURL: BASE_URL,
|
||||
headers: {
|
||||
// "Content-Type": "application/json",
|
||||
"ngrok-skip-browser-warning": "true"
|
||||
'ngrok-skip-browser-warning': 'true',
|
||||
},
|
||||
});
|
||||
|
||||
// Add request interceptor to inject access token
|
||||
axiosClient.interceptors.request.use(
|
||||
(config) => {
|
||||
if (typeof window !== "undefined") {
|
||||
const token = localStorage.getItem("token");
|
||||
if (typeof window !== 'undefined') {
|
||||
const token = localStorage.getItem('token');
|
||||
if (token && config.headers) {
|
||||
config.headers["Authorization"] = `Bearer ${token}`;
|
||||
config.headers['Authorization'] = `Bearer ${token}`;
|
||||
}
|
||||
}
|
||||
return config;
|
||||
},
|
||||
(error) => {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// Basic response interceptor
|
||||
@@ -33,12 +33,12 @@ axiosClient.interceptors.response.use(
|
||||
(error) => {
|
||||
// Standard error handling can be added here later
|
||||
return Promise.reject(error);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
export const axiosAuth = axios.create({
|
||||
baseURL: BASE_URL,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
});
|
||||
|
||||
export default axiosClient;
|
||||
|
||||
Reference in New Issue
Block a user