request.js 865 B

1234567891011121314151617181920212223242526272829
  1. const baseUrl = 'http://124.235.209.122:88';
  2. module.exports = {
  3. baseUrl,
  4. query({url, data, method = 'GET'}) {
  5. return new Promise((resolve, reject) => {
  6. wx.request({
  7. url: `${baseUrl}/${url}`,
  8. data: data,
  9. method: method,
  10. header: {'content-type': 'application/json'},
  11. dataType: 'json',
  12. success: resolve,
  13. fail: reject,
  14. });
  15. });
  16. },
  17. fetch({url, id}) {
  18. return new Promise((resolve, reject) => {
  19. wx.request({
  20. url: `${baseUrl}}/${url}/${id}`,
  21. method: 'GET',
  22. header: {'content-type': 'application/json'},
  23. dataType: 'json',
  24. success: resolve,
  25. fail: reject,
  26. });
  27. });
  28. },
  29. }