/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import axios, { AxiosInstance, AxiosResponse } from 'axios'; const getBaseURL = (env: string): string | undefined => { if (window.Cypress) { return Cypress.env('CY_' + env); // When running Cypress Intercept } else if (import.meta.env) { return import.meta.env['VITE_' + env]; // When running in development mode with Vite } return process.env['VUE_' + env]; // When building for production with Vue CLI }; const API = ({ headers = {}, params = {} } = {}): AxiosInstance => { const user = JSON.parse(localStorage.getItem('user') as string) ?? {}; const BASE_URL = getBaseURL('APP_USERS_V2_API'); const instance = axios.create({ baseURL: `${BASE_URL}/v2`, headers: { 'Content-type': 'application/json', 'Authorization': `Bearer ${user.token}`, ...headers, }, params, }); return instance; }; const UserServices = { getUsersSubUsers: (params: any): Promise => { return API({ params }).get('/users/user-and-sub-user'); }, }; export default UserServices;