2024-05-04 23:29:21 +08:00
|
|
|
|
import { http } from '@/utils/http'
|
2025-06-21 16:56:24 +08:00
|
|
|
|
|
2024-05-03 19:16:54 +08:00
|
|
|
|
export interface IFooItem {
|
|
|
|
|
id: string
|
|
|
|
|
name: string
|
|
|
|
|
}
|
2024-02-01 15:21:36 +08:00
|
|
|
|
|
2024-05-03 19:16:54 +08:00
|
|
|
|
/** GET 请求 */
|
2025-06-21 16:56:24 +08:00
|
|
|
|
export function getFooAPI(name: string) {
|
2025-04-12 14:05:58 +08:00
|
|
|
|
return http.get<IFooItem>('/foo', { name })
|
|
|
|
|
}
|
|
|
|
|
/** GET 请求;支持 传递 header 的范例 */
|
2025-06-21 16:56:24 +08:00
|
|
|
|
export function getFooAPI2(name: string) {
|
2025-04-12 11:02:48 +08:00
|
|
|
|
return http.get<IFooItem>('/foo', { name }, { 'Content-Type-100': '100' })
|
2024-05-03 19:16:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** POST 请求 */
|
2025-06-21 16:56:24 +08:00
|
|
|
|
export function postFooAPI(name: string) {
|
2025-04-12 14:05:58 +08:00
|
|
|
|
return http.post<IFooItem>('/foo', { name })
|
|
|
|
|
}
|
|
|
|
|
/** POST 请求;需要传递 query 参数的范例;微信小程序经常有同时需要query参数和body参数的场景 */
|
2025-06-21 16:56:24 +08:00
|
|
|
|
export function postFooAPI2(name: string) {
|
2025-04-12 14:05:58 +08:00
|
|
|
|
return http.post<IFooItem>('/foo', { name })
|
|
|
|
|
}
|
|
|
|
|
/** POST 请求;支持 传递 header 的范例 */
|
2025-06-21 16:56:24 +08:00
|
|
|
|
export function postFooAPI3(name: string) {
|
2025-04-12 11:02:48 +08:00
|
|
|
|
return http.post<IFooItem>('/foo', { name }, { name }, { 'Content-Type-100': '100' })
|
2024-05-04 23:29:21 +08:00
|
|
|
|
}
|