Skip to content

Instantly share code, notes, and snippets.

@hgl
Created July 30, 2015 10:03
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 hgl/6778051c1386dde04ecc to your computer and use it in GitHub Desktop.
Save hgl/6778051c1386dde04ecc to your computer and use it in GitHub Desktop.
// cancel request
let req = new Request(url);
fetch(req).catch(() => {
// reject with abort error
});
req.abort(); // abort fetch
// cancel stream reading
fetch(url).then(r => {
r.abort();
return r.json();
}).catch(() => {
// reject with abort error
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment