Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 1x 1x 1x 1x 1x 12x 27x 27x 27x 12x 2x 2x 2x 12x 12x 1x 1x 1x 12x 2x 1x 1x 12x | import { AxiosInstance, AxiosRequestConfig } from 'axios';
import { CommonSuccessResponse } from '@/types/service/common';
export const createApiHelper = (axios: AxiosInstance) => ({
get: async <T>(url: string, config?: AxiosRequestConfig): Promise<T> => {
const response = await axios.get<CommonSuccessResponse<T>>(url, config);
return response.data.data;
},
post: async <T>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<T> => {
const response = await axios.post<CommonSuccessResponse<T>>(url, data, config);
return response.data.data;
},
put: async <T>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<T> => {
const response = await axios.put<CommonSuccessResponse<T>>(url, data, config);
return response.data.data;
},
delete: async <T>(url: string, config?: AxiosRequestConfig): Promise<T> => {
const response = await axios.delete<CommonSuccessResponse<T>>(url, config);
return response.data.data;
},
patch: async <T>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<T> => {
const response = await axios.patch<CommonSuccessResponse<T>>(url, data, config);
return response.data.data;
},
});
|