foo.ts 895 B

1234567891011121314151617181920212223242526272829
  1. import { http } from '@/http/http'
  2. export interface IFooItem {
  3. id: string
  4. name: string
  5. }
  6. /** GET 请求 */
  7. export function getFooAPI(name: string) {
  8. return http.get<IFooItem>('/foo', { name })
  9. }
  10. /** GET 请求;支持 传递 header 的范例 */
  11. export function getFooAPI2(name: string) {
  12. return http.get<IFooItem>('/foo', { name }, { 'Content-Type-100': '100' })
  13. }
  14. /** POST 请求 */
  15. export function postFooAPI(name: string) {
  16. return http.post<IFooItem>('/foo', { name })
  17. }
  18. /** POST 请求;需要传递 query 参数的范例;微信小程序经常有同时需要query参数和body参数的场景 */
  19. export function postFooAPI2(name: string) {
  20. return http.post<IFooItem>('/foo', { name })
  21. }
  22. /** POST 请求;支持 传递 header 的范例 */
  23. export function postFooAPI3(name: string) {
  24. return http.post<IFooItem>('/foo', { name }, { name }, { 'Content-Type-100': '100' })
  25. }