xinelu-doctor-app/api/request.js

28 lines
528 B
JavaScript
Raw Normal View History

2023-09-19 15:31:55 +08:00
import baseurl from './baseurl.js'
var request = function(config) {
return new Promise((resolve, rejected) => {
2023-11-10 10:43:14 +08:00
// uni.showLoading({
// title: ''
// });
2023-09-19 15:31:55 +08:00
uni.request({
url: baseurl + config.url,
data: config.data,
method: config.method,
timeout: 10000,
header: {
Authorization: 'Bearer' + ' ' + uni.getStorageSync('token')
},
success(res) {
2023-11-10 10:43:14 +08:00
// uni.hideLoading();
2023-09-19 15:31:55 +08:00
resolve(res.data)
},
fail(err) {
2023-11-10 10:43:14 +08:00
// uni.hideLoading();
2023-09-19 15:31:55 +08:00
rejected(err)
}
})
})
}
2023-11-10 10:43:14 +08:00
export default request