Merge branch 'dev' into feat/consultation-82
This commit is contained in:
@@ -37,9 +37,20 @@ export async function getList(path: string, params: any = null, name: string = '
|
||||
}
|
||||
}
|
||||
|
||||
export async function getDetail(path: string, id: number | string, name: string = 'item') {
|
||||
export async function getDetail(path: string, id: number | string, name: string = 'item', params?: any) {
|
||||
try {
|
||||
const resp = await xfetch(`${path}/${id}`, 'GET')
|
||||
let paramStr = ''
|
||||
if (params && typeof params === 'object' && Object.keys(params).length > 0) {
|
||||
const searchParams = new URLSearchParams()
|
||||
for (const key in params) {
|
||||
if (params[key] !== null && params[key] !== undefined && params[key] !== '') {
|
||||
searchParams.append(key, params[key])
|
||||
}
|
||||
}
|
||||
const queryString = searchParams.toString()
|
||||
paramStr += queryString ? `?${queryString}` : ''
|
||||
}
|
||||
const resp = await xfetch(`${path}/${id}${paramStr}`, 'GET')
|
||||
const result: any = {}
|
||||
result.success = resp.success
|
||||
result.body = (resp.body as Record<string, any>) || {}
|
||||
|
||||
Reference in New Issue
Block a user