Created
October 20, 2019 14:10
-
-
Save lucas-pelton/b2bec212e37ad3cb38d4f8b249146f81 to your computer and use it in GitHub Desktop.
CloudFlare worker promise race boilerplate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
response = await Promise.race([ | |
fetch('https://possibly.slow.io/' + options.token + '/get', { | |
method: 'POST', | |
body: JSON.stringify(data), | |
}), | |
new Promise((_, reject) => | |
setTimeout(() => reject(new Error('Timeout')), options.timeout) | |
), | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment