Adds the ability to abort requests using AbortController and signals under the hood.
Only compatible with browsers that support AbortControllers. Otherwise, you could use a (partial) polyfill.
import AbortAddon from "wretch/addons/abort"const [c, w] = wretch("...") .addon(AbortAddon()) .get() .onAbort((_) => console.log("Aborted !")) .controller();w.text((_) => console.log("should never be called"));c.abort();// Or :const controller = new AbortController();wretch("...") .addon(AbortAddon()) .signal(controller) .get() .onAbort((_) => console.log("Aborted !")) .text((_) => console.log("should never be called"));controller.abort(); Copy
import AbortAddon from "wretch/addons/abort"const [c, w] = wretch("...") .addon(AbortAddon()) .get() .onAbort((_) => console.log("Aborted !")) .controller();w.text((_) => console.log("should never be called"));c.abort();// Or :const controller = new AbortController();wretch("...") .addon(AbortAddon()) .signal(controller) .get() .onAbort((_) => console.log("Aborted !")) .text((_) => console.log("should never be called"));controller.abort();
Adds the ability to abort requests using AbortController and signals under the hood.
Only compatible with browsers that support AbortControllers. Otherwise, you could use a (partial) polyfill.