fetch.js 378 B

1234567891011121314151617
  1. const app = getApp()
  2. module.exports = (url, data, method = 'GET', header = {}) => {
  3. wx.showLoading({ title: 'Loading...' })
  4. return new Promise((resolve, reject) => {
  5. wx.request({
  6. url: app.config.apiBase + url,
  7. data,
  8. header,
  9. method,
  10. dataType: 'json',
  11. success: resolve,
  12. fail: reject,
  13. complete: wx.hideLoading
  14. })
  15. })
  16. }