mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-10-20 16:43:42 +08:00
refactor(projects): axios封装完成
This commit is contained in:
27
src/service/api/demo.ts
Normal file
27
src/service/api/demo.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import type { ResponseDictionary, Dictionary } from '@/interface';
|
||||
import { request, resultMiddleware } from '../request';
|
||||
import { fecthDictionaryMiddleware } from '../middleware';
|
||||
|
||||
// 接口示例
|
||||
|
||||
/**
|
||||
* 获取数据字典(不加middleware处理)
|
||||
* @param keyword - 关键词
|
||||
*/
|
||||
export function fetchDictionary(keyword: string) {
|
||||
return request.post<ResponseDictionary[]>('/emoss-entropy/ehe/model/getByIndicator', {
|
||||
indiCatorName: keyword
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据字典(加middleware处理)
|
||||
* @param keyword - 关键词
|
||||
*/
|
||||
export async function fetchDictionaryWithMiddleware(keyword: string) {
|
||||
const res = await request.post<ResponseDictionary[]>('/emoss-entropy/ehe/model/getByIndicator', {
|
||||
indiCatorName: keyword
|
||||
});
|
||||
|
||||
return resultMiddleware<Dictionary[]>(fecthDictionaryMiddleware, [res]);
|
||||
}
|
Reference in New Issue
Block a user