-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttpClient.ts
More file actions
26 lines (22 loc) · 800 Bytes
/
httpClient.ts
File metadata and controls
26 lines (22 loc) · 800 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import axios, { AxiosInstance, AxiosResponse, AxiosError } from 'axios';
import { prodUrl } from '../config/urls';
const ANALYTICS_BASE_URL = prodUrl;
const httpClient: AxiosInstance = axios.create({
baseURL: ANALYTICS_BASE_URL,
headers: {
'Content-Type': 'application/json',
},
timeout: 10000, // 10 second timeout
});
httpClient.interceptors.response.use(
(response: AxiosResponse) => response,
(error: AxiosError) => {
if (error.code === 'ERR_NETWORK') {
console.warn('Analytics endpoint unreachable - continuing without tracking');
return Promise.resolve({ data: null, status: 200, statusText: 'OK', headers: {}, config: error.config });
}
console.error('HTTP Client error:', error);
return Promise.reject(error);
}
);
export default httpClient;