I'm trying to get a returned variable from inside a function and us it in the rest of the page, i'm getting no luck at all, is there a way to get "AmazonvastTagUrl" from inside the function, outside the function, so as I can use it later down the page?
this what have so far:
var AmazonvastTagURL = 'https://pubads.g.doubleclick.net/gampad/ads?cust_params='
console.log('%cAdysis%c Amazon AdTag:', "background: rgb(19 177 118);color:#FFF;padding:5px;border-radius: 5px;line-height: 10px;", "", AmazonvastTagURL);
// Request Bids
apstag.fetchBids({
slots: [{
slotID: 'SOMESLOT',
mediaType: 'video'
//Slot name created in the portal, aligns to individual request for this bid
}],
timeout: PREBID_TIMEOUT / 1.5
},
function(bids) {
console.log('%cAdysis%c Amazon Pre-Roll Bid Logs', "background: rgb(19 177 118);color:#FFF;padding:5px;border-radius: 5px;line-height: 10px;", "", bids);
// console.log('%cAdysis%c Amazon Pre-Roll Bid Logs', "background: rgb(19 177 118);color:#FFF;padding:5px;border-radius: 5px;line-height: 10px;","", encodedQsParams);
//Pass bids into the function that will append the key values onto the VAST tag
setTimeout(() => {
handleVideoBids(bids);
}, 100)
});
function handleVideoBids(bids) {
if (bids.length > 0) {
AmazonvastTagURL += bids[0].encodedQsParams;
console.log('%cAdysis%c Amazon encodedQsParams Params:', "background: rgb(19 177 118);color:#FFF;padding:5px;border-radius: 5px;line-height: 10px;", "", AmazonvastTagURL);
}
};