-
-
Save dtmrc/49f31271979e32a705ce76da4503b0a1 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 hidden or 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
Handling timeout in Axios
https://medium.com/@masnun/handling-timeout-in-axios-479269d83c68
Abu Ashraf Masnun Jun 17, 2019