3
0

uni.promisify.adaptor.js 373 B

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