微信小程序解决异步封装http请求的问题

app.js

postData: function (url, data) {
	var that = this;
	return new Promise(function (resolve, reject) {
		wx.request({
			url: that.globalData.baseURL + url,
			data: data,
	        method: "GET",
            header: {
            	"Content-Type": "application/json;charset=UTF-8",
                "token": that.globalData.token
            },
            success: function (res) {
            	resolve(res.data);
            },
            fail: function (res) {
            	reject(res);
            },
		})
	});
},

猜你喜欢

转载自blog.csdn.net/qq_42521446/article/details/87027570
0条评论
添加一条新回复