api calls simplified

This commit is contained in:
dimitar committed 2025-11-23 17:12:14 +01:00
1 parent 6cbed4e8d1
commit 1b50bfd2ee
7 files changed
+136 -49

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
import axios from 'axios';
import { API_BASE_URL } from '../config/api';
export const apiClient = axios.create({
baseURL: API_BASE_URL,
headers: {
'Content-Type': 'application/json',
},
});
// Helper to set the auth token for a request
export const setAuthToken = (token: string) => {
if (token) {
apiClient.defaults.headers.common['Authorization'] = `Bearer ${token}`;
} else {
delete apiClient.defaults.headers.common['Authorization'];
}
};