Files
edr-platform/apps/edr-freight-web/portal/src/services/crud.ts
2026-05-20 08:15:29 +03:00

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();