一、依赖包
package.json
二、封装
api/index.ts
import axios from "axios";
import { stringify } from 'qs';
export async function get(url: string, params?: any) {
return axios({
url,
method: 'get',
params,
}).then(({ data }) => data);
}
export async function post(url: string, params?: any) {
return axios({
url,
method: 'post',
data: stringify(params),
}).then(({ data }) => data);
}
三、使用
import { post, get } from '../api';
get(interFace.iceBreakerCoupon, params)
.then((res)=>{
console.log('res', res)
})

您已经阅读00:00:00欢迎留言评论,喜欢的话就为作者点个赞或者赏颗糖吧! 分享
发表评论(不少于3个字符) 取消回复