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

Feature Request: AbortController shortcut syntax #23

Closed
willin opened this issue Nov 8, 2021 · 8 comments
Closed

Feature Request: AbortController shortcut syntax #23

willin opened this issue Nov 8, 2021 · 8 comments
Labels
enhancement New feature or request

Comments

@willin
Copy link

willin commented Nov 8, 2021

ref: https://developer.mozilla.org/en-US/docs/Web/API/AbortController

@mvdschee mvdschee mentioned this issue Dec 22, 2021
@MichaelGitArt
Copy link

😶

@bloor
Copy link

bloor commented May 4, 2022

A request-abort is much needed, especially for React/Vue projects.
Please provide a solution.

@xuxucode
Copy link

It does support AbortController. $fetch accepts options whatever you passed in: https://github.com/unjs/ohmyfetch/blob/main/src/fetch.ts#L127.

For example:

  const controller = new AbortController();
  const signal = controller.signal;
  $fetch(url, { signal });

  controller.abort();

@nozomuikuta nozomuikuta added the enhancement New feature or request label Jan 11, 2023
@bf
Copy link

bf commented Feb 13, 2023

AbortController already works like @xuxucode has posted. I tried it. I think we can close this!

@pi0
Copy link
Member

pi0 commented Feb 13, 2023

Indeed. AbortController is supported univerally. I was keeping issue open if we can make a better shortcut syntax for ofetch for canceling requests..

@CaptainFalcon92
Copy link

CaptainFalcon92 commented Apr 10, 2023

In case it could help as inspiration, vueuse provides an abort() function from its version of useFetch()
https://github.com/vueuse/vueuse/blob/main/packages/core/useFetch/index.ts#L359
https://vueuse.org/core/useFetch/#aborting-a-request

The AbortController instance is created internally.

Using ofetch through Nuxt, i mostly use the built-in useFetch composables - not the vueuse one - thus not enjoying this easy-cancellable wizardry. Still it looks like the implementation could be borrowed.

@Hebilicious Hebilicious changed the title Feature Request: AbortController Feature Request: AbortController shortcut syntax Aug 8, 2023
@pi0
Copy link
Member

pi0 commented Aug 22, 2023

We expose an auto polyfilled version of AbortController with #268

@MickL
Copy link

MickL commented Feb 28, 2024

In case it could help as inspiration, vueuse provides an abort() function from its version of useFetch() https://github.com/vueuse/vueuse/blob/main/packages/core/useFetch/index.ts#L359 https://vueuse.org/core/useFetch/#aborting-a-request

I would also prefer to have a simple abort() function

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

No branches or pull requests

9 participants