feat(request): get & post 请求

This commit is contained in:
菲鸽
2024-02-01 15:21:36 +08:00
parent 58c6ebe870
commit e5732c36fb
7 changed files with 360 additions and 248 deletions

23
src/service/foo.ts Normal file
View File

@@ -0,0 +1,23 @@
import { http } from '@/utils/http'
import type { FooItem } from './foo.d'
export { FooItem }
/** get 请求 */
export const getFoo = (name: string) => {
return http<FooItem>({
url: `/foo`,
method: 'GET',
query: { name },
})
}
/** get 请求 */
export const postFoo = (name: string) => {
return http<FooItem>({
url: `/foo`,
method: 'POST',
query: { name }, // post 请求也支持 query
data: { name },
})
}