import axios, { AxiosInstance, AxiosResponse, AxiosRequestConfig } from "axios"; interface ApiWrapperOptions { baseURL?: string; headers?: Record; } class ApiWrapper { private axiosInstance: AxiosInstance; constructor(options: ApiWrapperOptions = {}) { this.axiosInstance = axios.create({ baseURL: options.baseURL || "", headers: options.headers || {}, }); } async request( method: string, endpoint: string, data: any = {}, params: any = {} ): Promise { try { const response: AxiosResponse = await this.axiosInstance({ method, url: endpoint, data, params, }); return response.data; } catch (error) { throw new Error(`Error making API request: ${error.message}`); } } } export default ApiWrapper;