Skip to content

Instantly share code, notes, and snippets.

@schovi
Created January 16, 2017 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schovi/6d37fe04dd15a2e31e6cc102c5a1d0d3 to your computer and use it in GitHub Desktop.
Save schovi/6d37fe04dd15a2e31e6cc102c5a1d0d3 to your computer and use it in GitHub Desktop.
Simple javascript fetch request with ability to be abort.
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