Explorar o código

Merge branch 'base'

feige996 hai 1 ano
pai
achega
446376481e
Modificáronse 3 ficheiros con 11 adicións e 4 borrados
  1. 1 1
      package.json
  2. 2 2
      src/service/index/foo.ts
  3. 8 1
      src/utils/http.ts

+ 1 - 1
package.json

@@ -1,7 +1,7 @@
 {
   "name": "unibest",
   "type": "commonjs",
-  "version": "2.6.1",
+  "version": "2.6.2",
   "description": "unibest - 最好的 uniapp 开发模板",
   "author": {
     "name": "feige996",

+ 2 - 2
src/service/index/foo.ts

@@ -6,10 +6,10 @@ export interface IFooItem {
 
 /** GET 请求 */
 export const getFooAPI = (name: string) => {
-  return http.get<IFooItem>('/foo', { name })
+  return http.get<IFooItem>('/foo', { name }, { 'Content-Type-100': '100' })
 }
 
 /** POST 请求 */
 export const postFooAPI = (name: string) => {
-  return http.post<IFooItem>('/foo', { name }, { name })
+  return http.post<IFooItem>('/foo', { name }, { name }, { 'Content-Type-100': '100' })
 }

+ 8 - 1
src/utils/http.ts

@@ -48,11 +48,16 @@ export const http = <T>(options: CustomRequestOptions) => {
  * @param query 请求query参数
  * @returns
  */
-export const httpGet = <T>(url: string, query?: Record<string, any>) => {
+export const httpGet = <T>(
+  url: string,
+  query?: Record<string, any>,
+  header?: Record<string, any>,
+) => {
   return http<T>({
     url,
     query,
     method: 'GET',
+    header,
   })
 }
 
@@ -67,12 +72,14 @@ export const httpPost = <T>(
   url: string,
   data?: Record<string, any>,
   query?: Record<string, any>,
+  header?: Record<string, any>,
 ) => {
   return http<T>({
     url,
     query,
     data,
     method: 'POST',
+    header,
   })
 }