mirror of
https://github.com/eliasstepanik/core.git
synced 2026-01-11 09:38:27 +00:00
15 lines
360 B
TypeScript
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;
|
|
});
|
|
}
|