我需要让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;
}