From b59e8993967659af24e038194d487adec2c94ba6 Mon Sep 17 00:00:00 2001 From: feige996 <1020102647@qq.com> Date: Sat, 12 Apr 2025 11:02:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0header=E7=9A=84?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/service/index/foo.ts | 4 ++-- src/utils/http.ts | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/service/index/foo.ts b/src/service/index/foo.ts index acf5aa8..340b8ba 100644 --- a/src/service/index/foo.ts +++ b/src/service/index/foo.ts @@ -6,10 +6,10 @@ export interface IFooItem { /** GET 请求 */ export const getFooAPI = (name: string) => { - return http.get('/foo', { name }) + return http.get('/foo', { name }, { 'Content-Type-100': '100' }) } /** POST 请求 */ export const postFooAPI = (name: string) => { - return http.post('/foo', { name }, { name }) + return http.post('/foo', { name }, { name }, { 'Content-Type-100': '100' }) } diff --git a/src/utils/http.ts b/src/utils/http.ts index 4e3f38c..13045c9 100644 --- a/src/utils/http.ts +++ b/src/utils/http.ts @@ -48,11 +48,16 @@ export const http = (options: CustomRequestOptions) => { * @param query 请求query参数 * @returns */ -export const httpGet = (url: string, query?: Record) => { +export const httpGet = ( + url: string, + query?: Record, + header?: Record, +) => { return http({ url, query, method: 'GET', + header, }) } @@ -67,12 +72,14 @@ export const httpPost = ( url: string, data?: Record, query?: Record, + header?: Record, ) => { return http({ url, query, data, method: 'POST', + header, }) }