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
Request for options access to AbortControllers #27
Labels
not a bug
This will not be worked on
Comments
So I don't think we'll need to support them explicitly, for a couple reasons:
|
Also should note that since we pass through options, to native fetch you can use Abort Controllers just like you could with fetch. AbortController with native fetch// Step 1: Create an instance of AbortController
const controller = new AbortController()
const signal = controller.signal
// Step 2: Initiate a fetch request and pass the signal as an option
fetch('https://api.example.com/data', { signal })
.then(response => response.json())
.then(console.log)
.catch(error => {
if (error.name === 'AbortError') {
console.log('Fetch aborted')
} else {
console.error('Fetch error:', error)
}
})
// Step 3: Abort the fetch request (this could be triggered by a user action, for example)
setTimeout(() => controller.abort(), 5000) AbortController with itty-fetcher// Step 1: Create an instance of AbortController
const controller = new AbortController()
const signal = controller.signal
// Step 2: Initiate a fetch request and pass the signal as an option (3rd argument)
fetcher()
.get('https://api.example.com/data', {}, { signal })
.then(console.log)
.catch(error => {
if (error.name === 'AbortError') {
console.log('Fetch aborted')
} else {
console.error('Fetch error:', error)
}
})
// Step 3: Abort the fetch request (this could be triggered by a user action, for example)
setTimeout(() => controller.abort(), 5000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Love the simplicity and syntax of this library! The one thing preventing me from using it some production code is a way to work with Abort Controllers. Do you have a preferred method with this library (maybe I'm over looking something) or is that a feature worth adding to your roadmap?
The text was updated successfully, but these errors were encountered: