uni.promisify.adaptor.js 348 B

1234567891011121314
  1. uni.addInterceptor({
  2. returnValue(res) {
  3. if (!(!!res && (typeof res === "object" || typeof res === "function") && typeof res.then ===
  4. "function")) {
  5. return res;
  6. }
  7. return new Promise((resolve, reject) => {
  8. res.then((res) => {
  9. if (!res) return resolve(res)
  10. return res[0] ? reject(res[0]) : resolve(res[1])
  11. });
  12. });
  13. },
  14. });