38 lines
828 B
TypeScript
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
|
|
}
|
|
}
|
|
}
|