优雅的轮询

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);
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容