fecrprd/common/request.js

25 lines
499 B
JavaScript
Raw Normal View History

2023-03-02 09:44:12 +08:00
export const request = (options) => {
return new Promise((resolve, reject) => {
uni.request({
2023-03-07 18:03:25 +08:00
url: "https://testapi.fecribd.com" + options.url,
2023-03-02 09:44:12 +08:00
data: options.data || {},
2023-03-07 18:03:25 +08:00
method: options.method || 'POST',
header:{
'Authorization': uni.getStorageSync("token") || null
},
2023-03-02 09:44:12 +08:00
success: (res) => {
resolve(res.data)
},
fail: (err) => {
uni.showToast({
title: '请求接口失败'
})
reject(err)
},
catch: (e) => {
console.log(e);
}
})
})
}