Skip to content

Instantly share code, notes, and snippets.

@toddzebert
Created March 27, 2017 04:08
Show Gist options
  • Save toddzebert/135578e9faf006b73656c360b7e616e2 to your computer and use it in GitHub Desktop.
Save toddzebert/135578e9faf006b73656c360b7e616e2 to your computer and use it in GitHub Desktop.
getAds code for use with getAd.js, and simAsync.js
// requires https://gist.github.com/toddzebert/996e297c1c081d19378eaf5f29dc75bb
// requires https://gist.github.com/toddzebert/ec087188b813e6490abab2cf0feb2ad5
var getAds = function (data) {
return new Promise( (resolve, reject) => {
Promise.race([getAd(data), getAd(data), getAd(data)])
.then(result => {
data.ads = result; resolve(data);
})
.catch(result => {
data.ads = result; reject(data);
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment