优雅的轮询

2019-10-18  本文已影响0人  爱代码的派派星
async resultFun(key) {
      try {
        const res = await base.ajaxGet(API.EXCHANGE_RESULT, {
          key: key
        });
        return res.data.id;
      } catch (err) {
        if (err.code == "9302") {
          // 排队
          await sleep(1500);
          return this.resultFun(this.key);
        } else {
          throw err;
        }
      }
    }
//此处调用轮询函数
const orderId = await this.resultFun(res.data.key);
       //调用轮询后需要接受其参数的函数
        const order = await this.wxFunction(orderId);
上一篇下一篇

猜你喜欢

热点阅读