23 lines
628 B
TypeScript
23 lines
628 B
TypeScript
import axios from 'axios';
|
|
|
|
const instance = axios.create({ baseURL: '/api', timeout: 20000 });
|
|
|
|
instance.interceptors.response.use(
|
|
(res) => {
|
|
const body = res.data;
|
|
if (body && typeof body === 'object' && 'code' in body) {
|
|
return body.code === 0 ? body.data : Promise.reject(body);
|
|
}
|
|
return body;
|
|
},
|
|
(err) => Promise.reject(err),
|
|
);
|
|
|
|
export function fetchTrace(shortCode: string): Promise<any> {
|
|
return instance.get(`/public/trace/${shortCode}`) as unknown as Promise<any>;
|
|
}
|
|
|
|
export function fetchAppInfo(): Promise<any> {
|
|
return instance.get('/settings/public') as unknown as Promise<any>;
|
|
}
|