等待返回功能,直到操作完成

时间:2019-09-11 23:59:53

标签: javascript prebid.js

我需要让currentFunction等待返回其请求,直到执行baseUrl。

我遇到的问题是adsRequest在baseUrl执行之前在currentFunction中返回。

currentFunction function(){
...
     let base = []     

     function baseUrl(url){
        base.push(url)
      };

        pbjs.requestBids({
          timeout: 2000,
          //callback that executes when all the bid responses are back or the timeout hits
          //the callback receives two parameters
          bidsBackHandler : function(bids, timeout) {
            console.log(bids)
            console.log(timeout)
            var videoUrl = pbjs.adServers.dfp.buildVideoUrl({
              adUnit: videoAdUnit,
              params: {
                iu: '/188641797/video/test'
              }
            });
            baseUrl(videoUrl)
          }
        });
      });

     adsRequest.adTagUrl = `${base[0]}${targetingQueryParams}`;

     return adsRequest;
}

0 个答案:

没有答案