feat: 使用 http.get 替代 httpGet

This commit is contained in:
菲鸽 2024-05-04 23:29:21 +08:00
parent 7beb03a89e
commit cc53167750
2 changed files with 10 additions and 2 deletions

View File

@ -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<IFooItem>('/foo', { name })
return http.get<IFooItem>('/foo', { name })
}
/** POST 请求 */
@ -27,3 +27,7 @@ export const postFooAPI = (name: string) => {
data: { name },
})
}
/** POST 请求 - 再次简化,看大家是否喜欢这种简化 */
export const postFooAPI2 = (name: string) => {
return http.post<IFooItem>('/foo', { name }, { name })
}

View File

@ -41,6 +41,7 @@ export const http = <T>(options: CustomRequestOptions) => {
})
})
}
/**
* GET
* @param url
@ -74,3 +75,6 @@ export const httpPost = <T>(
method: 'POST',
})
}
http.get = httpGet
http.post = httpPost