Created
March 10, 2017 08:07
-
-
Save mohemohe/c1ec20ba2ab9bd18faa9540264b886f9 to your computer and use it in GitHub Desktop.
fetchAPIにタイムアウトがないのでawaitしたときに死ぬからつらい
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
| new Promise(async(resolve, reject) => { | |
| let timeoutHendle = setTimeout(() => { | |
| reject(); | |
| }, 5000); | |
| let response: Response = null; | |
| if (init == null) { | |
| response = await fetch(input); | |
| } else { | |
| response = await fetch(input, init); | |
| } | |
| clearTimeout(timeoutHendle); | |
| resolve(response); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment