Hacker News new | ask | show | jobs
by capableweb 1015 days ago
Did you actually look at the link I sent you? It's absolutely not low level. If you know how to use window.fetch, you know how to use AbortController already.

   controller = new AbortController();
   const signal = controller.signal;
   fetch("http://example.com", { signal: signal })
   // abort request
   controller.abort();
It basically couldn't be simpler? What sort of API would you like to be able to cancel requests?
1 comments

That's a toy example! In reality in a complex app you'd usually be aborting far from where the fetch is created, and you'd have large promise chains where the semantics of cancellation are non-obvious and even unintuitive.