二次封装微信网络请求
作者:互联网
class WHRequest {
constructor(){
this.BASE_URL=''
}
request(url, method, params) {
return new Promise((resolve, reject) => {
wx.request({
url:this.BASE_URL+url,
method,
data:params,
success(res) {
resolve(res.data.data)
},
fail(err) {
reject(err)
}
})
})
}
get(url,params){
return this.request(url,'GET',params)
}
post(url,data){
return this.request(url,'POST',data)
}
}
const whRequest = new WHRequest()
export default whRequest
标签:封装,err,二次,url,微信,request,params,return,data 来源: https://www.cnblogs.com/wayhome123/p/15987949.html