2024-05-04 23:29:21 +08:00

34 lines
795 B
TypeScript

import { http } from '@/utils/http'
export interface IFooItem {
id: string
name: string
}
/** GET 请求 */
export const getFooAPI = (name: string) => {
return http<IFooItem>({
url: `/foo`,
method: 'GET',
query: { name },
})
}
/** GET 请求 - 再次简化,看大家是否喜欢这种简化 */
export const getFooAPI2 = (name: string) => {
return http.get<IFooItem>('/foo', { name })
}
/** POST 请求 */
export const postFooAPI = (name: string) => {
return http<IFooItem>({
url: `/foo`,
method: 'POST',
query: { name }, // post 请求也支持 query
data: { name },
})
}
/** POST 请求 - 再次简化,看大家是否喜欢这种简化 */
export const postFooAPI2 = (name: string) => {
return http.post<IFooItem>('/foo', { name }, { name })
}