Interface AbortWretch

interface AbortWretch {
    signal: (<T, C, R>(this: T & Wretch<T, C, R>, controller: AbortController) => this);
}

Properties

Properties

signal: (<T, C, R>(this: T & Wretch<T, C, R>, controller: AbortController) => this)

Associates a custom controller with the request.

Useful when you need to use your own AbortController, otherwise wretch will create a new controller itself.

const controller = new AbortController()

// Associates the same controller with multiple requests
wretch("url1")
.addon(AbortAddon())
.signal(controller)
.get()
.json()
wretch("url2")
.addon(AbortAddon())
.signal(controller)
.get()
.json()

// Aborts both requests
controller.abort()

Type declaration

    • <T, C, R>(this, controller): this
    • Type Parameters

      Parameters

      • this: T & Wretch<T, C, R>
      • controller: AbortController

        An instance of AbortController

      Returns this