erp-platform/ui/src/services/form.service.ts
2025-08-12 12:39:09 +03:00

38 lines
828 B
TypeScript

import { AxiosError, Method } from 'axios'
import { URLSearchParams } from 'url'
import { GridDto } from '../proxy/form/models'
import apiService from './api.service'
export const getList = (data: Record<string, string>) => {
try {
return apiService.fetchData<GridDto>({
method: 'GET',
url: '/api/app/list-form-select/grid',
params: data,
})
} catch (error) {
if (error instanceof AxiosError) {
return error.response?.data
}
}
}
export const dynamicFetch = (
url: string,
method: Method | string,
params?: URLSearchParams | any,
data?: any,
) => {
try {
return apiService.fetchData({
method,
url: '/api/app/' + url,
params,
data,
})
} catch (error) {
if (error instanceof AxiosError) {
return error.response?.data
}
}
}