feat: 增加header的支持
This commit is contained in:
parent
18de3f3e22
commit
b59e899396
@ -6,10 +6,10 @@ export interface IFooItem {
|
|||||||
|
|
||||||
/** GET 请求 */
|
/** GET 请求 */
|
||||||
export const getFooAPI = (name: string) => {
|
export const getFooAPI = (name: string) => {
|
||||||
return http.get<IFooItem>('/foo', { name })
|
return http.get<IFooItem>('/foo', { name }, { 'Content-Type-100': '100' })
|
||||||
}
|
}
|
||||||
|
|
||||||
/** POST 请求 */
|
/** POST 请求 */
|
||||||
export const postFooAPI = (name: string) => {
|
export const postFooAPI = (name: string) => {
|
||||||
return http.post<IFooItem>('/foo', { name }, { name })
|
return http.post<IFooItem>('/foo', { name }, { name }, { 'Content-Type-100': '100' })
|
||||||
}
|
}
|
||||||
|
@ -48,11 +48,16 @@ export const http = <T>(options: CustomRequestOptions) => {
|
|||||||
* @param query 请求query参数
|
* @param query 请求query参数
|
||||||
* @returns
|
* @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>({
|
return http<T>({
|
||||||
url,
|
url,
|
||||||
query,
|
query,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
|
header,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,12 +72,14 @@ export const httpPost = <T>(
|
|||||||
url: string,
|
url: string,
|
||||||
data?: Record<string, any>,
|
data?: Record<string, any>,
|
||||||
query?: Record<string, any>,
|
query?: Record<string, any>,
|
||||||
|
header?: Record<string, any>,
|
||||||
) => {
|
) => {
|
||||||
return http<T>({
|
return http<T>({
|
||||||
url,
|
url,
|
||||||
query,
|
query,
|
||||||
data,
|
data,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
header,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user