mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
60 lines
1.2 KiB
TypeScript
60 lines
1.2 KiB
TypeScript
import { client } from "@/utils/api";
|
|
import { AxiosRequestConfig, AxiosResponse } from "axios";
|
|
|
|
|
|
class ApiService {
|
|
async get<T = any>(
|
|
url: string,
|
|
config?: AxiosRequestConfig
|
|
): Promise<T> {
|
|
const response: AxiosResponse<T> =
|
|
await client.get(url, config);
|
|
|
|
return response.data;
|
|
}
|
|
|
|
async post<T = any>(
|
|
url: string,
|
|
data?: any,
|
|
config?: AxiosRequestConfig
|
|
): Promise<T> {
|
|
const response: AxiosResponse<T> =
|
|
await client.post(url, data, config);
|
|
|
|
return response.data;
|
|
}
|
|
|
|
async put<T = any>(
|
|
url: string,
|
|
data?: any,
|
|
config?: AxiosRequestConfig
|
|
): Promise<T> {
|
|
const response: AxiosResponse<T> =
|
|
await client.put(url, data, config);
|
|
|
|
return response.data;
|
|
}
|
|
|
|
async patch<T = any>(
|
|
url: string,
|
|
data?: any,
|
|
config?: AxiosRequestConfig
|
|
): Promise<T> {
|
|
const response: AxiosResponse<T> =
|
|
await client.patch(url, data, config);
|
|
|
|
return response.data;
|
|
}
|
|
|
|
async delete<T = any>(
|
|
url: string,
|
|
config?: AxiosRequestConfig
|
|
): Promise<T> {
|
|
const response: AxiosResponse<T> =
|
|
await client.delete(url, config);
|
|
|
|
return response.data;
|
|
}
|
|
}
|
|
|
|
export const api = new ApiService(); |