Skip to content

Instantly share code, notes, and snippets.

@hgl
Created July 30, 2015 10:03
Show Gist options
  • Select an option

  • Save hgl/6778051c1386dde04ecc to your computer and use it in GitHub Desktop.

Select an option

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