import axios, { AxiosInstance } from 'axios'; import log from 'loglevel'; const logResource = (a: AxiosInstance) => { a.interceptors.response.use(r => { log.debug(`[${r.config.method?.toUpperCase()}] ${r.config.url}`); return r; }, e => { log.error(`[${e.config.method?.toUpperCase()}] ${e.config.url} failed with ${e.response?.status} ${e.response?.statusText}`); return Promise.reject(e); }); } export const apiAxiosInstance = axios.create({ baseURL: '/api/', headers: { 'accept': 'application/json', "Content-Type": "application/json" }, }) logResource(apiAxiosInstance) export const evepraisalAxiosInstance = axios.create({ baseURL: '/appraisal/', headers: { 'accept': 'application/json', "Content-Type": "application/json" }, }) logResource(evepraisalAxiosInstance) export const esiAxiosInstance = axios.create({ baseURL: '/esi/', headers: { 'accept': 'application/json', "Content-Type": "application/json" }, }) logResource(esiAxiosInstance)