feat: http请求
This commit is contained in:
parent
b59e899396
commit
cf2a9f5aa5
@ -6,10 +6,22 @@ export interface IFooItem {
|
|||||||
|
|
||||||
/** GET 请求 */
|
/** GET 请求 */
|
||||||
export const getFooAPI = (name: string) => {
|
export const getFooAPI = (name: string) => {
|
||||||
|
return http.get<IFooItem>('/foo', { name })
|
||||||
|
}
|
||||||
|
/** GET 请求;支持 传递 header 的范例 */
|
||||||
|
export const getFooAPI2 = (name: string) => {
|
||||||
return http.get<IFooItem>('/foo', { name }, { 'Content-Type-100': '100' })
|
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 })
|
||||||
|
}
|
||||||
|
/** POST 请求;需要传递 query 参数的范例;微信小程序经常有同时需要query参数和body参数的场景 */
|
||||||
|
export const postFooAPI2 = (name: string) => {
|
||||||
|
return http.post<IFooItem>('/foo', { name })
|
||||||
|
}
|
||||||
|
/** POST 请求;支持 传递 header 的范例 */
|
||||||
|
export const postFooAPI3 = (name: string) => {
|
||||||
return http.post<IFooItem>('/foo', { name }, { name }, { 'Content-Type-100': '100' })
|
return http.post<IFooItem>('/foo', { name }, { name }, { 'Content-Type-100': '100' })
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,7 @@ export const http = <T>(options: CustomRequestOptions) => {
|
|||||||
* GET 请求
|
* GET 请求
|
||||||
* @param url 后台地址
|
* @param url 后台地址
|
||||||
* @param query 请求query参数
|
* @param query 请求query参数
|
||||||
|
* @param header 请求头,默认为json格式
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export const httpGet = <T>(
|
export const httpGet = <T>(
|
||||||
@ -66,6 +67,7 @@ export const httpGet = <T>(
|
|||||||
* @param url 后台地址
|
* @param url 后台地址
|
||||||
* @param data 请求body参数
|
* @param data 请求body参数
|
||||||
* @param query 请求query参数,post请求也支持query,很多微信接口都需要
|
* @param query 请求query参数,post请求也支持query,很多微信接口都需要
|
||||||
|
* @param header 请求头,默认为json格式
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export const httpPost = <T>(
|
export const httpPost = <T>(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user