39 lines
825 B
TypeScript
39 lines
825 B
TypeScript
|
|
import apiService from '@/services/api.service'
|
||
|
|
import { GridDto } from './models'
|
||
|
|
import { AxiosError, Method } from 'axios'
|
||
|
|
import { URLSearchParams } from 'url'
|
||
|
|
|
||
|
|
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
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|