import axios, { AxiosInstance, AxiosRequestConfig } from 'axios' export default class HttpClient { private readonly client: AxiosInstance private config: AxiosRequestConfig = {} constructor(endpoint: string) { this.client = axios.create({ baseURL: endpoint, headers: { 'Content-Type': 'application/json', }, }) this.config = {} } setConfig(config: AxiosRequestConfig): HttpClient { this.config = config return this } get(endpoint: string, params: T = {} as T): Promise

{ return this.client.get(endpoint, { params, ...this.config }) } post(endpoint: string, data: T = {} as T): Promise

{ return this.client.post(endpoint, data, this.config) } delete(endpoint: string, params: T = {} as T): Promise

{ return this.client.delete(endpoint, { params, ...this.config }) } }