29 lines
896 B
TypeScript
Raw Normal View History

2024-05-04 23:29:21 +08:00
import { http } from '@/utils/http'
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 请求 */
export function getFooAPI(name: string) {
2025-04-12 14:05:58 +08:00
return http.get<IFooItem>('/foo', { name })
}
/** GET 请求;支持 传递 header 的范例 */
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 请求 */
export function postFooAPI(name: string) {
2025-04-12 14:05:58 +08:00
return http.post<IFooItem>('/foo', { name })
}
/** POST 请求;需要传递 query 参数的范例微信小程序经常有同时需要query参数和body参数的场景 */
export function postFooAPI2(name: string) {
2025-04-12 14:05:58 +08:00
return http.post<IFooItem>('/foo', { name })
}
/** POST 请求;支持 传递 header 的范例 */
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
}