Visitar URL original
Roy · Issue #1256 · github/fetch · GitHub
The Wayback Machine - https://web.archive.org/web/20230131201414/https://github.com/github/fetch/issues/1256
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Roy #1256

Open
RoyGila opened this issue Jan 31, 2023 · 0 comments
Open

Roy #1256

RoyGila opened this issue Jan 31, 2023 · 0 comments

Comments

@RoyGila
Copy link

RoyGila commented Jan 31, 2023

import 'yet-another-abortcontroller-polyfill'
import {fetch} from 'whatwg-fetch'

// use native browser implementation if it supports aborting
const abortableFetch = ('signal' in new Request('')) ? window.fetch : fetch

const controller = new AbortController()

abortableFetch('/avatars', {
signal: controller.signal
}).catch(function(ex) {
if (ex.name === 'AbortError') {
console.log('request aborted')
}
})

// some time later...
controller.abort()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant