-
-
Save fmoliveira/b8bc96d64c0b2189bb5f90c54d3c9b56 to your computer and use it in GitHub Desktop.
Add a pseudo timeout/deadline to a request using the ES6 fetch api
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
Promise.race([ | |
fetch('/foo'), | |
new Promise((_, reject) => | |
setTimeout(() => reject(new Error('Timeout')), 7000) | |
) | |
]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment