request.js 415 B

1234567891011121314151617
  1. module.exports = (options) => {
  2. return new Promise((resolve, reject) => {
  3. options = Object.assign(options, {
  4. success(result) {
  5. if (result.statusCode === 200) {
  6. resolve(result.data);
  7. } else {
  8. reject(result);
  9. }
  10. },
  11. fail: reject,
  12. });
  13. wx.request(options);
  14. });
  15. };