From cc53167750a659a27b0b6aa7ec75fb3d1e277772 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8F=B2=E9=B8=BD?= <1020103647@qq.com> Date: Sat, 4 May 2024 23:29:21 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BD=BF=E7=94=A8=20http.get=20?= =?UTF-8?q?=E6=9B=BF=E4=BB=A3=20httpGet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/service/index/foo.ts | 8 ++++++-- src/utils/http.ts | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/service/index/foo.ts b/src/service/index/foo.ts index 7263dfc..dac3519 100644 --- a/src/service/index/foo.ts +++ b/src/service/index/foo.ts @@ -1,4 +1,4 @@ -import { http, httpGet } from '@/utils/http' +import { http } from '@/utils/http' export interface IFooItem { id: string name: string @@ -15,7 +15,7 @@ export const getFooAPI = (name: string) => { /** GET 请求 - 再次简化,看大家是否喜欢这种简化 */ export const getFooAPI2 = (name: string) => { - return httpGet('/foo', { name }) + return http.get('/foo', { name }) } /** POST 请求 */ @@ -27,3 +27,7 @@ export const postFooAPI = (name: string) => { data: { name }, }) } +/** POST 请求 - 再次简化,看大家是否喜欢这种简化 */ +export const postFooAPI2 = (name: string) => { + return http.post('/foo', { name }, { name }) +} diff --git a/src/utils/http.ts b/src/utils/http.ts index db4c6aa..4e3f38c 100644 --- a/src/utils/http.ts +++ b/src/utils/http.ts @@ -41,6 +41,7 @@ export const http = (options: CustomRequestOptions) => { }) }) } + /** * GET 请求 * @param url 后台地址 @@ -74,3 +75,6 @@ export const httpPost = ( method: 'POST', }) } + +http.get = httpGet +http.post = httpPost