Harshith Mullapudi a3798db1e6 fix: cli init
2025-10-09 20:13:15 +05:30

15 lines
360 B
TypeScript

import axios from 'axios';
// Intercept axios requests and add token to the request
export function interceptAxios(token: string) {
axios.interceptors.request.use((axiosConfig) => {
if (!axiosConfig.headers.Authorization) {
if (token) {
axiosConfig.headers.Authorization = `Bearer ${token}`;
}
}
return axiosConfig;
});
}