Created
January 16, 2017 14:38
-
-
Save schovi/6d37fe04dd15a2e31e6cc102c5a1d0d3 to your computer and use it in GitHub Desktop.
Simple javascript fetch request with ability to be abort.
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
const abortableFetch(url, options) { | |
var abort; | |
const promise = new Promise((resolve, reject) => { | |
abort = reject | |
fetch(url, options).then(resolve, reject) | |
}) | |
promise.abort = abort | |
return promise | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment