fecrprd/common/request.js

25 lines
499 B
JavaScript

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