You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
high-mini/Utils/Request.js

38 lines
874 B

let app = getApp();
function request(method, url, data) {
return new Promise((resolve) => {
uni.showLoading({
title: '加载中...'
});
uni.request({
method: method,
url: url,
data: data,
header: {
'Accept': "*/*",
'content-type': 'application/json;charset=utf-8',
// 'token': app.globalData.token, //您可根据如本地存储或者vuex再此处使用逻辑或 来插入token
'Authorization': app.globalData.token, //有的时候这里不一定是 token 还可能是 Authorization
},
success(res) {
resolve(res)
uni.hideLoading()
},
fail(err) {
uni.showToast({
title: '请求失败',
icon: 'none',
duration: 1500,
})
uni.hideLoading()
}
})
})
}
function POST(method, url, data) {
return request(method, url, data)
}
module.exports = {
POST
}