diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f6d9b4..5fc42bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ + +# [2.8.0](https://github.com/elbywan/wretch/compare/2.7.1...2.8.0) (2023-12-30) + + +### :factory: New feature(s) + +* addon.resolver can now be a function ([0bf9aa8](https://github.com/elbywan/wretch/commit/0bf9aa8)), closes [#212](https://github.com/elbywan/wretch/issues/212) + + + ## [2.7.1](https://github.com/elbywan/wretch/compare/2.7.0...2.7.1) (2023-11-19) diff --git a/README.md b/README.md index a4055ce..7e3d5b9 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@
-##### Wretch 2.7 is now live 🎉 ! Please have a look at the [releases](https://github.com/elbywan/wretch/releases) and the [changelog](https://github.com/elbywan/wretch/blob/master/CHANGELOG.md) after each update for new features and breaking changes. If you want to try out the hot stuff, please look into the [dev](https://github.com/elbywan/wretch/tree/dev) branch. +##### Wretch 2.8 is now live 🎉 ! Please have a look at the [releases](https://github.com/elbywan/wretch/releases) and the [changelog](https://github.com/elbywan/wretch/blob/master/CHANGELOG.md) after each update for new features and breaking changes. If you want to try out the hot stuff, please look into the [dev](https://github.com/elbywan/wretch/tree/dev) branch. ##### And if you like the library please consider becoming a [sponsor](https://github.com/sponsors/elbywan) ❤️. diff --git a/docs/api/functions/addons_abort.default.html b/docs/api/functions/addons_abort.default.html index 14d4e46..35730e3 100644 --- a/docs/api/functions/addons_abort.default.html +++ b/docs/api/functions/addons_abort.default.html @@ -5,4 +5,4 @@ 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();
-

Returns WretchAddon<AbortWretch, AbortResolver>

Generated using TypeDoc

\ No newline at end of file +

Returns WretchAddon<AbortWretch, AbortResolver>

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/api/functions/addons_perfs.default.html b/docs/api/functions/addons_perfs.default.html index b763a7d..3d51b98 100644 --- a/docs/api/functions/addons_perfs.default.html +++ b/docs/api/functions/addons_perfs.default.html @@ -9,4 +9,4 @@

For node.js, there is a little extra work to do :

// Node.js only
const { performance, PerformanceObserver } = require("perf_hooks");

wretch.polyfills({
fetch: function (url, opts) {
performance.mark(url + " - begin");
return fetch(url, opts).then(res => {
performance.mark(url + " - end");
setTimeout(() => performance.measure(res.url, url + " - begin", url + " - end"), 0);
return res;
});
},
// other polyfills…
performance: performance,
PerformanceObserver: PerformanceObserver,
});
-

Returns WretchAddon<unknown, PerfsAddon>

Generated using TypeDoc

\ No newline at end of file +

Returns WretchAddon<unknown, PerfsAddon>

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/api/functions/addons_progress.default.html b/docs/api/functions/addons_progress.default.html index fd14ff8..f2613cc 100644 --- a/docs/api/functions/addons_progress.default.html +++ b/docs/api/functions/addons_progress.default.html @@ -2,4 +2,4 @@

Compatible with all platforms implementing the TransformStream WebAPI.

import ProgressAddon from "wretch/addons/progress"

wretch("some_url")
// Register the addon
.addon(ProgressAddon())
.get()
// Log the progress as a percentage of completion
.progress((loaded, total) => console.log(`${(loaded / total * 100).toFixed(0)}%`))
-

Returns WretchAddon<unknown, ProgressResolver>

Generated using TypeDoc

\ No newline at end of file +

Returns WretchAddon<unknown, ProgressResolver>

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/api/functions/index.default-1.html b/docs/api/functions/index.default-1.html index acde829..7b9441c 100644 --- a/docs/api/functions/index.default-1.html +++ b/docs/api/functions/index.default-1.html @@ -5,4 +5,4 @@

Parameters

Returns Wretch

A fresh wretch instance

-

Generated using TypeDoc

\ No newline at end of file +

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/api/functions/middlewares_dedupe.dedupe.html b/docs/api/functions/middlewares_dedupe.dedupe.html index 90b6fac..9c2f983 100644 --- a/docs/api/functions/middlewares_dedupe.dedupe.html +++ b/docs/api/functions/middlewares_dedupe.dedupe.html @@ -18,4 +18,4 @@

This function is called when resolving the fetch response from duplicate calls. By default it clones the response to allow reading the body from multiple sources.

-

Parameters

Returns ConfiguredMiddleware

Generated using TypeDoc

\ No newline at end of file +

Parameters

Returns ConfiguredMiddleware

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/api/functions/middlewares_delay.delay.html b/docs/api/functions/middlewares_delay.delay.html index 1c635b4..b5f2609 100644 --- a/docs/api/functions/middlewares_delay.delay.html +++ b/docs/api/functions/middlewares_delay.delay.html @@ -5,4 +5,4 @@

The request will be delayed by that amount of time.

-

Parameters

Returns ConfiguredMiddleware

Generated using TypeDoc

\ No newline at end of file +

Parameters

Returns ConfiguredMiddleware

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/api/functions/middlewares_retry.retry.html b/docs/api/functions/middlewares_retry.retry.html index fea19c6..a3e3349 100644 --- a/docs/api/functions/middlewares_retry.retry.html +++ b/docs/api/functions/middlewares_retry.retry.html @@ -5,4 +5,4 @@
import wretch from 'wretch'
import { retry } from 'wretch/middlewares'

wretch().middlewares([
retry({
// Options - defaults below
delayTimer: 500,
delayRamp: (delay, nbOfAttempts) => delay * nbOfAttempts,
maxAttempts: 10,
until: (response, error) => response && response.ok,
onRetry: null,
retryOnNetworkError: false,
resolveWithLatestResponse: false,
skip: undefined
})
])

// You can also return a Promise, which is useful if you want to inspect the body:
wretch().middlewares([
retry({
until: response =>
response.clone().json().then(body =>
body.field === 'something'
)
})
])
-

Parameters

Returns ConfiguredMiddleware

Generated using TypeDoc

\ No newline at end of file +

Parameters

Returns ConfiguredMiddleware

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/api/functions/middlewares_throttlingCache.throttlingCache.html b/docs/api/functions/middlewares_throttlingCache.throttlingCache.html index 8b91fb4..cf910de 100644 --- a/docs/api/functions/middlewares_throttlingCache.throttlingCache.html +++ b/docs/api/functions/middlewares_throttlingCache.throttlingCache.html @@ -41,4 +41,4 @@

If set, a Response returned from the cache whill be flagged with a property name equal to this option.

-

Parameters

Returns ConfiguredMiddleware & {
    cache: Map<any, any>;
    inflight: Map<any, any>;
    throttling: Set<unknown>;
    cacheResponse(key, response) => void;
}

Generated using TypeDoc

\ No newline at end of file +

Parameters

Returns ConfiguredMiddleware & {
    cache: Map<any, any>;
    inflight: Map<any, any>;
    throttling: Set<unknown>;
    cacheResponse(key, response) => void;
}

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/api/interfaces/addons_abort.AbortResolver.html b/docs/api/interfaces/addons_abort.AbortResolver.html index e636c2f..340cbb8 100644 --- a/docs/api/interfaces/addons_abort.AbortResolver.html +++ b/docs/api/interfaces/addons_abort.AbortResolver.html @@ -1,14 +1,14 @@ -AbortResolver | wretch

Interface AbortResolver

Hierarchy

  • AbortResolver

Properties

controller +AbortResolver | wretch

Interface AbortResolver

Hierarchy

  • AbortResolver

Properties

controller: (<T, C, R>(this) => [any, AbortResolver])

Type declaration

    • <T, C, R>(this): [any, AbortResolver]
    • Returns the provided or generated AbortController plus the wretch response chain as a pair.

      // We need the controller outside the chain
      const [c, w] = wretch("url")
      .addon(AbortAddon())
      .get()
      .controller()

      // Resume with the chain
      w.onAbort(_ => console.log("ouch")).json()

      // Later on…
      c.abort()
      -

      Type Parameters

      Parameters

      Returns [any, AbortResolver]

onAbort: (<T, C, R>(this, cb) => AbortResolver)

Type declaration

setTimeout: (<T, C, R>(this, time, controller?) => AbortResolver)

Type declaration

onAbort: (<T, C, R>(this, cb) => AbortResolver)

Type declaration

setTimeout: (<T, C, R>(this, time, controller?) => AbortResolver)

Type declaration

    • <T, C, R>(this, time, controller?): AbortResolver
    • Aborts the request after a fixed time.

      If you use a custom AbortController associated with the request, pass it as the second argument.

      // 1 second timeout
      wretch("...").addon(AbortAddon()).get().setTimeout(1000).json(_ =>
      // will not be called if the request timeouts
      )

      Type Parameters

      Parameters

      • this: C & WretchResponseChain<T, C, R>
      • time: number

        Time in milliseconds

      • Optional controller: AbortController

        An instance of AbortController

        -

      Returns AbortResolver

Generated using TypeDoc

\ No newline at end of file +

Returns AbortResolver

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/api/interfaces/addons_abort.AbortWretch.html b/docs/api/interfaces/addons_abort.AbortWretch.html index f023b95..b20ca32 100644 --- a/docs/api/interfaces/addons_abort.AbortWretch.html +++ b/docs/api/interfaces/addons_abort.AbortWretch.html @@ -1,8 +1,8 @@ -AbortWretch | wretch

Interface AbortWretch

Hierarchy

  • AbortWretch

Properties

signal +AbortWretch | wretch

Interface AbortWretch

Hierarchy

  • AbortWretch

Properties

Properties

signal: (<T, C, R>(this, controller) => AbortWretch)

Type declaration

    • <T, C, R>(this, controller): AbortWretch
    • 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 Parameters

      Parameters

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

        An instance of AbortController

        -

      Returns AbortWretch

Generated using TypeDoc

\ No newline at end of file +

Returns AbortWretch

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/api/interfaces/addons_formData.FormDataAddon.html b/docs/api/interfaces/addons_formData.FormDataAddon.html index 368430a..2490951 100644 --- a/docs/api/interfaces/addons_formData.FormDataAddon.html +++ b/docs/api/interfaces/addons_formData.FormDataAddon.html @@ -1,4 +1,4 @@ -FormDataAddon | wretch

Interface FormDataAddon

Hierarchy

  • FormDataAddon

Methods

formData +FormDataAddon | wretch

Interface FormDataAddon

Hierarchy

  • FormDataAddon

Methods

Methods

  • Converts the javascript object to a FormData and sets the request body.

    const form = {
    hello: "world",
    duck: "Muscovy",
    };

    wretch("...").addons(FormDataAddon).formData(form).post();
    @@ -21,4 +21,4 @@

    Type Parameters

    Parameters

    • this: T & Wretch<T, C, R>
    • formObject: object

      An object which will be converted to a FormData

    • Optional recursive: boolean | string[]

      If true, will recurse through all nested objects. Can be set as an array of string to exclude specific keys.

      -

    Returns FormDataAddon

Generated using TypeDoc

\ No newline at end of file +

Returns FormDataAddon

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/api/interfaces/addons_formUrl.FormUrlAddon.html b/docs/api/interfaces/addons_formUrl.FormUrlAddon.html index c24d16c..20229a6 100644 --- a/docs/api/interfaces/addons_formUrl.FormUrlAddon.html +++ b/docs/api/interfaces/addons_formUrl.FormUrlAddon.html @@ -1,8 +1,8 @@ -FormUrlAddon | wretch

Interface FormUrlAddon

Hierarchy

  • FormUrlAddon

Methods

formUrl +FormUrlAddon | wretch

Interface FormUrlAddon

Hierarchy

  • FormUrlAddon

Methods

Methods

  • Converts the input parameter to an url encoded string and sets the content-type header and body. If the input argument is already a string, skips the conversion part.

    const form = { a: 1, b: { c: 2 } };
    const alreadyEncodedForm = "a=1&b=%7B%22c%22%3A2%7D";

    // Automatically sets the content-type header to "application/x-www-form-urlencoded"
    wretch("...").addon(FormUrlAddon).formUrl(form).post();
    wretch("...").addon(FormUrlAddon).formUrl(alreadyEncodedForm).post();

    Type Parameters

    Parameters

    • this: T & Wretch<T, C, R>
    • input: string | object

      An object to convert into an url encoded string or an already encoded string

      -

    Returns FormUrlAddon

Generated using TypeDoc

\ No newline at end of file +

Returns FormUrlAddon

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/api/interfaces/addons_perfs.PerfsAddon.html b/docs/api/interfaces/addons_perfs.PerfsAddon.html index 3466edf..8fa5d6d 100644 --- a/docs/api/interfaces/addons_perfs.PerfsAddon.html +++ b/docs/api/interfaces/addons_perfs.PerfsAddon.html @@ -1,4 +1,4 @@ -PerfsAddon | wretch

Interface PerfsAddon

Hierarchy

  • PerfsAddon

Properties

perfs +PerfsAddon | wretch

Interface PerfsAddon

Hierarchy

  • PerfsAddon

Properties

Properties

perfs: (<T, C, R>(this, cb?) => PerfsAddon)

Type declaration

    • <T, C, R>(this, cb?): PerfsAddon
    • Performs a callback on the API performance timings of the request.

      Warning: Still experimental on browsers and node.js

      -

      Type Parameters

      Parameters

      • this: C & WretchResponseChain<T, C, R>
      • Optional cb: ((timing) => void)
          • (timing): void
          • Parameters

            • timing: any

            Returns void

      Returns PerfsAddon

Generated using TypeDoc

\ No newline at end of file +

Type Parameters

Parameters

  • this: C & WretchResponseChain<T, C, R>
  • Optional cb: ((timing) => void)
      • (timing): void
      • Parameters

        • timing: any

        Returns void

Returns PerfsAddon

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/api/interfaces/addons_progress.ProgressResolver.html b/docs/api/interfaces/addons_progress.ProgressResolver.html index 286e2af..c2cbdd3 100644 --- a/docs/api/interfaces/addons_progress.ProgressResolver.html +++ b/docs/api/interfaces/addons_progress.ProgressResolver.html @@ -1,8 +1,8 @@ -ProgressResolver | wretch

Interface ProgressResolver

Hierarchy

  • ProgressResolver

Properties

progress +ProgressResolver | wretch

Interface ProgressResolver

Hierarchy

  • ProgressResolver

Properties

Properties

progress: (<T, C, R>(this, onProgress) => ProgressResolver)

Type declaration

    • <T, C, R>(this, onProgress): ProgressResolver
    • Provides a way to register a callback to be invoked one or multiple times during the download. The callback receives the current progress as two arguments, the number of bytes loaded and the total number of bytes to load.

      Under the hood: this method adds a middleware to the chain that will intercept the response and replace the body with a new one that will emit the progress event.

      import ProgressAddon from "wretch/addons/progress"

      wretch("some_url")
      // Register the addon
      .addon(ProgressAddon())
      .get()
      // Log the progress as a percentage of completion
      .progress((loaded, total) => console.log(`${(loaded / total * 100).toFixed(0)}%`))

      Type Parameters

      Parameters

      • this: C & WretchResponseChain<T, C, R>
      • onProgress: ((loaded, total) => void)

        A callback that will be called one or multiple times with the number of bytes loaded and the total number of bytes to load.

        -
          • (loaded, total): void
          • Parameters

            • loaded: number
            • total: number

            Returns void

      Returns ProgressResolver

Generated using TypeDoc

\ No newline at end of file +
    • (loaded, total): void
    • Parameters

      • loaded: number
      • total: number

      Returns void

Returns ProgressResolver

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/api/interfaces/addons_queryString.QueryStringAddon.html b/docs/api/interfaces/addons_queryString.QueryStringAddon.html index 72ab31c..0771d2a 100644 --- a/docs/api/interfaces/addons_queryString.QueryStringAddon.html +++ b/docs/api/interfaces/addons_queryString.QueryStringAddon.html @@ -1,4 +1,4 @@ -QueryStringAddon | wretch

Hierarchy

  • QueryStringAddon

Methods

query +QueryStringAddon | wretch

Hierarchy

  • QueryStringAddon

Methods

Methods

  • Converts a javascript object to query parameters, then appends this query string to the current url. String values are used as the query string verbatim.

    Pass true as the second argument to replace existing query parameters.

    @@ -9,4 +9,4 @@
    // Using wretch with qs

    const queryObject = { some: { nested: "objects" } };
    const w = wretch("https://example.com/").addon(QueryStringAddon)

    // Use .qs inside .query :

    w.query(qs.stringify(queryObject));

    // Use .defer :

    const qsWretch = w.defer((w, url, { qsQuery, qsOptions }) => (
    qsQuery ? w.query(qs.stringify(qsQuery, qsOptions)) : w
    ));

    qsWretch
    .url("https://example.com/")
    .options({ qs: { query: queryObject } });

    Type Parameters

    Parameters

    • this: T & Wretch<T, C, R>
    • qp: string | object

      An object which will be converted, or a string which will be used verbatim.

      -
    • Optional replace: boolean

    Returns QueryStringAddon

Generated using TypeDoc

\ No newline at end of file +
  • Optional replace: boolean
  • Returns QueryStringAddon

    Generated using TypeDoc

    \ No newline at end of file diff --git a/docs/api/interfaces/index.Wretch.html b/docs/api/interfaces/index.Wretch.html index de0f8ee..f10b977 100644 --- a/docs/api/interfaces/index.Wretch.html +++ b/docs/api/interfaces/index.Wretch.html @@ -2,7 +2,7 @@
    import wretch from "wretch"

    // Reusable wretch instance
    const w = wretch("https://domain.com", { mode: "cors" })

    Immutability : almost every method of this class return a fresh Wretch object.

    -

    Type Parameters

    Hierarchy

    Body Types

    Type Parameters

    • Self = unknown

    • Chain = unknown

    • Resolver = undefined

    Hierarchy

    • Wretch

    Body Types

    HTTP

    delete fetch @@ -30,52 +30,52 @@
    wretch("...").body("hello").put();
    // Note that calling put/post methods with a non-object argument is equivalent:
    wretch("...").put("hello");

    Parameters

    • this: Self & Wretch<Self, Chain, Resolver>
    • contents: any

      The body contents

      -

    Returns Wretch<Self, Chain, Resolver>

    • Sets the "Content-Type" header, stringifies an object and sets the request body.

      +

    Returns Wretch<Self, Chain, Resolver>

    • Sets the "Content-Type" header, stringifies an object and sets the request body.

      const jsonObject = { a: 1, b: 2, c: 3 };
      wretch("...").json(jsonObject).post();
      // Note that calling an 'http verb' method with an object argument is equivalent:
      wretch("...").post(jsonObject);

      Parameters

      • this: Self & Wretch<Self, Chain, Resolver>
      • jsObject: object

        An object which will be serialized into a JSON

      • Optional contentType: string

        A custom content type.

        -

      Returns Wretch<Self, Chain, Resolver>

    HTTP

    • Performs a DELETE request.

      +

    Returns Wretch<Self, Chain, Resolver>

    HTTP

    Returns Resolver extends undefined
        ? Chain & WretchResponseChain<Self, Chain, Resolver>
        : Resolver

    Helpers

    Helpers

    Returns Wretch<Self, Chain, Resolver>

    Returns W & Self & Wretch<Self & W, Chain & R, Resolver>

    Returns Wretch<Self, Chain, Resolver>

    Returns Wretch<Self, Chain, Resolver>

    Returns Wretch<Self, Chain, Resolver>

    Returns Wretch<Self, Chain, Resolver>

    Returns Wretch<Self, Chain, Resolver>

    Returns Wretch<Self, Chain, Resolver>

    Returns Wretch<Self, Chain, Resolver>

    Returns Wretch<Self, Chain, Resolver>

    Returns Self & Wretch<Self, Chain, ResolverReturn>

    Generated using TypeDoc

    \ No newline at end of file +

    Returns Wretch<Self, Chain, Resolver>

    Generated using TypeDoc

    \ No newline at end of file diff --git a/docs/api/interfaces/index.WretchError.html b/docs/api/interfaces/index.WretchError.html index 86b0900..c622eaa 100644 --- a/docs/api/interfaces/index.WretchError.html +++ b/docs/api/interfaces/index.WretchError.html @@ -1,5 +1,5 @@ WretchError | wretch

    Interface WretchError

    An Error enhanced with status, text and body.

    -

    Hierarchy

    • Error
      • WretchError

    Properties

    Hierarchy

    • Error
      • WretchError

    Properties

    Properties

    json?: any
    message: string
    name: string
    response: WretchResponse
    stack?: string
    status: number
    text?: string
    url: string

    Generated using TypeDoc

    \ No newline at end of file +

    Properties

    json?: any
    message: string
    name: string
    response: WretchResponse
    stack?: string
    status: number
    text?: string
    url: string

    Generated using TypeDoc

    \ No newline at end of file diff --git a/docs/api/interfaces/index.WretchResponseChain.html b/docs/api/interfaces/index.WretchResponseChain.html index ef19c83..33c9a51 100644 --- a/docs/api/interfaces/index.WretchResponseChain.html +++ b/docs/api/interfaces/index.WretchResponseChain.html @@ -1,6 +1,6 @@ WretchResponseChain | wretch

    Interface WretchResponseChain<T, Self, R>

    The resolver interface to chaining catchers and extra methods after the request has been sent. Ultimately returns a Promise.

    -

    Type Parameters

    • T

    • Self = unknown

    • R = undefined

    Hierarchy

    • WretchResponseChain

    Catchers

    Type Parameters

    • T

    • Self = unknown

    • R = undefined

    Hierarchy

    • WretchResponseChain

    Catchers

    badRequest error fetchError forbidden @@ -17,45 +17,45 @@

    Catchers

    badRequest: ((this, cb) => WretchResponseChain<T, Self, R>)

    Type declaration

    error: ((this, code, cb) => WretchResponseChain<T, Self, R>)

    Type declaration

      • (this, code, cb): WretchResponseChain<T, Self, R>
      • Catches an http response with a specific error code or name and performs a callback.

        +
    error: ((this, code, cb) => WretchResponseChain<T, Self, R>)

    Type declaration

      • (this, code, cb): WretchResponseChain<T, Self, R>
      • Catches an http response with a specific error code or name and performs a callback.

        The original request is passed along the error and can be used in order to perform an additional request.

        wretch("/resource")
        .get()
        .unauthorized(async (error, req) => {
        // Renew credentials
        const token = await wretch("/renewtoken").get().text();
        storeToken(token);
        // Replay the original request with new credentials
        return req.auth(token).get().unauthorized((err) => {
        throw err;
        }).json();
        })
        .json()
        // The promise chain is preserved as expected
        // ".then" will be performed on the result of the original request
        // or the replayed one (if a 401 error was thrown)
        .then(callback);
        -

        Parameters

        Returns WretchResponseChain<T, Self, R>

    fetchError: ((this, cb) => WretchResponseChain<T, Self, R>)

    Type declaration

    fetchError: ((this, cb) => WretchResponseChain<T, Self, R>)

    Type declaration

    forbidden: ((this, cb) => WretchResponseChain<T, Self, R>)

    Type declaration

      • (this, cb): WretchResponseChain<T, Self, R>
      • Catches a forbidden request (http code 403) and performs a callback.

        +
    forbidden: ((this, cb) => WretchResponseChain<T, Self, R>)

    Type declaration

    internalError: ((this, cb) => WretchResponseChain<T, Self, R>)

    Type declaration

      • (this, cb): WretchResponseChain<T, Self, R>
      • Catches an internal server error (http code 500) and performs a callback.

        +
    internalError: ((this, cb) => WretchResponseChain<T, Self, R>)

    Type declaration

    notFound: ((this, cb) => WretchResponseChain<T, Self, R>)

    Type declaration

      • (this, cb): WretchResponseChain<T, Self, R>
      • Catches a "not found" request (http code 404) and performs a callback.

        +
    notFound: ((this, cb) => WretchResponseChain<T, Self, R>)

    Type declaration

    timeout: ((this, cb) => WretchResponseChain<T, Self, R>)

    Type declaration

      • (this, cb): WretchResponseChain<T, Self, R>
      • Catches a timeout (http code 408) and performs a callback.

        +
    timeout: ((this, cb) => WretchResponseChain<T, Self, R>)

    Type declaration

    unauthorized: ((this, cb) => WretchResponseChain<T, Self, R>)

    Type declaration

      • (this, cb): WretchResponseChain<T, Self, R>
      • Catches an unauthorized request (http code 401) and performs a callback.

        +
    unauthorized: ((this, cb) => WretchResponseChain<T, Self, R>)

    Type declaration

    Response Type

    arrayBuffer: (<Result>(cb?) => Promise<Awaited<Result>>)

    Type declaration

      • <Result>(cb?): Promise<Awaited<Result>>
      • Read the payload and deserialize it as an ArrayBuffer object.

        +

    Response Type

    arrayBuffer: (<Result>(cb?) => Promise<Awaited<Result>>)

    Type declaration

      • <Result>(cb?): Promise<Awaited<Result>>
      • Read the payload and deserialize it as an ArrayBuffer object.

        wretch("...").get().arrayBuffer(arrayBuffer => …)
         
        -

        Type Parameters

        • Result = ArrayBuffer

        Parameters

        • Optional cb: ((type) => Result | Promise<Result>)
            • (type): Result | Promise<Result>
            • Parameters

              • type: ArrayBuffer

              Returns Result | Promise<Result>

        Returns Promise<Awaited<Result>>

    blob: (<Result>(cb?) => Promise<Awaited<Result>>)

    Type declaration

      • <Result>(cb?): Promise<Awaited<Result>>
      • Read the payload and deserialize it as a Blob.

        +

        Type Parameters

        • Result = ArrayBuffer

        Parameters

        • Optional cb: ((type) => Result | Promise<Result>)
            • (type): Result | Promise<Result>
            • Parameters

              • type: ArrayBuffer

              Returns Result | Promise<Result>

        Returns Promise<Awaited<Result>>

    blob: (<Result>(cb?) => Promise<Awaited<Result>>)

    Type declaration

      • <Result>(cb?): Promise<Awaited<Result>>
      • Read the payload and deserialize it as a Blob.

        wretch("...").get().blob(blob => …)
         
        -

        Type Parameters

        • Result = Blob

        Parameters

        • Optional cb: ((type) => Result | Promise<Result>)
            • (type): Result | Promise<Result>
            • Parameters

              • type: Blob

              Returns Result | Promise<Result>

        Returns Promise<Awaited<Result>>

    formData: (<Result>(cb?) => Promise<Awaited<Result>>)

    Type declaration

      • <Result>(cb?): Promise<Awaited<Result>>
      • Read the payload and deserialize it as a FormData object.

        +

        Type Parameters

        • Result = Blob

        Parameters

        • Optional cb: ((type) => Result | Promise<Result>)
            • (type): Result | Promise<Result>
            • Parameters

              • type: Blob

              Returns Result | Promise<Result>

        Returns Promise<Awaited<Result>>

    formData: (<Result>(cb?) => Promise<Awaited<Result>>)

    Type declaration

      • <Result>(cb?): Promise<Awaited<Result>>
      • Read the payload and deserialize it as a FormData object.

        wretch("...").get().formData(formData => …)
         
        -

        Type Parameters

        • Result = FormData

        Parameters

        • Optional cb: ((type) => Result | Promise<Result>)
            • (type): Result | Promise<Result>
            • Parameters

              • type: FormData

              Returns Result | Promise<Result>

        Returns Promise<Awaited<Result>>

    json: (<Result>(cb?) => Promise<Awaited<Result>>)

    Type declaration

      • <Result>(cb?): Promise<Awaited<Result>>
      • Read the payload and deserialize it as JSON.

        +

        Type Parameters

        • Result = FormData

        Parameters

        • Optional cb: ((type) => Result | Promise<Result>)
            • (type): Result | Promise<Result>
            • Parameters

              • type: FormData

              Returns Result | Promise<Result>

        Returns Promise<Awaited<Result>>

    json: (<Result>(cb?) => Promise<Awaited<Result>>)

    Type declaration

      • <Result>(cb?): Promise<Awaited<Result>>
      • Read the payload and deserialize it as JSON.

        wretch("...").get().json((json) => console.log(Object.keys(json)));
         
        -

        Type Parameters

        • Result = unknown

        Parameters

        • Optional cb: ((type) => Result | Promise<Result>)
            • (type): Result | Promise<Result>
            • Parameters

              • type: any

              Returns Result | Promise<Result>

        Returns Promise<Awaited<Result>>

    res: (<Result>(cb?) => Promise<Awaited<Result>>)

    Type declaration

      • <Result>(cb?): Promise<Awaited<Result>>
      • The handler for the raw fetch Response. +

        Type Parameters

        • Result = unknown

        Parameters

        • Optional cb: ((type) => Result | Promise<Result>)
            • (type): Result | Promise<Result>
            • Parameters

              • type: any

              Returns Result | Promise<Result>

        Returns Promise<Awaited<Result>>

    res: (<Result>(cb?) => Promise<Awaited<Result>>)

    Type declaration

      • <Result>(cb?): Promise<Awaited<Result>>
      • The handler for the raw fetch Response. Check the MDN documentation for more details on the Response class.

        wretch("...").get().res((response) => console.log(response.url));
         
        -

        Type Parameters

        Parameters

        • Optional cb: ((type) => Result | Promise<Result>)
            • (type): Result | Promise<Result>
            • Parameters

              Returns Result | Promise<Result>

        Returns Promise<Awaited<Result>>

    text: (<Result>(cb?) => Promise<Awaited<Result>>)

    Type declaration

      • <Result>(cb?): Promise<Awaited<Result>>
      • Retrieves the payload as a string.

        +

        Type Parameters

        Parameters

        • Optional cb: ((type) => Result | Promise<Result>)
            • (type): Result | Promise<Result>
            • Parameters

              Returns Result | Promise<Result>

        Returns Promise<Awaited<Result>>

    text: (<Result>(cb?) => Promise<Awaited<Result>>)

    Type declaration

      • <Result>(cb?): Promise<Awaited<Result>>
      • Retrieves the payload as a string.

        wretch("...").get().text((txt) => console.log(txt));
         
        -

        Type Parameters

        • Result = string

        Parameters

        • Optional cb: ((type) => Result | Promise<Result>)
            • (type): Result | Promise<Result>
            • Parameters

              • type: string

              Returns Result | Promise<Result>

        Returns Promise<Awaited<Result>>

    Generated using TypeDoc

    \ No newline at end of file +

    Type Parameters

    Parameters

    Returns Promise<Awaited<Result>>

    Generated using TypeDoc

    \ No newline at end of file diff --git a/docs/api/modules/addons.html b/docs/api/modules/addons.html index d7baa2f..aa25a07 100644 --- a/docs/api/modules/addons.html +++ b/docs/api/modules/addons.html @@ -1,4 +1,4 @@ -addons | wretch

    Module addons

    References

    AbortResolver +addons | wretch

    Module addons

    References

    AbortResolver AbortWretch FormDataAddon FormUrlAddon diff --git a/docs/api/modules/addons_abort.html b/docs/api/modules/addons_abort.html index 5e00555..f53959c 100644 --- a/docs/api/modules/addons_abort.html +++ b/docs/api/modules/addons_abort.html @@ -1,4 +1,4 @@ -addons/abort | wretch

    Module addons/abort

    Index

    Interfaces

    AbortResolver +addons/abort | wretch

    Generated using TypeDoc

    \ No newline at end of file diff --git a/docs/api/modules/addons_formData.html b/docs/api/modules/addons_formData.html index 9178bcc..4d397ae 100644 --- a/docs/api/modules/addons_formData.html +++ b/docs/api/modules/addons_formData.html @@ -1,3 +1,3 @@ -addons/formData | wretch

    Module addons/formData

    Index

    Interfaces

    FormDataAddon +addons/formData | wretch

    Generated using TypeDoc

    \ No newline at end of file diff --git a/docs/api/modules/addons_formUrl.html b/docs/api/modules/addons_formUrl.html index 26b0bad..ef9634b 100644 --- a/docs/api/modules/addons_formUrl.html +++ b/docs/api/modules/addons_formUrl.html @@ -1,3 +1,3 @@ -addons/formUrl | wretch

    Module addons/formUrl

    Index

    Interfaces

    FormUrlAddon +addons/formUrl | wretch

    Generated using TypeDoc

    \ No newline at end of file diff --git a/docs/api/modules/addons_perfs.html b/docs/api/modules/addons_perfs.html index bb59a9f..af5f0cc 100644 --- a/docs/api/modules/addons_perfs.html +++ b/docs/api/modules/addons_perfs.html @@ -1,3 +1,3 @@ -addons/perfs | wretch

    Module addons/perfs

    Index

    Interfaces

    PerfsAddon +addons/perfs | wretch

    Generated using TypeDoc

    \ No newline at end of file diff --git a/docs/api/modules/addons_progress.html b/docs/api/modules/addons_progress.html index b5f3fb2..27e0018 100644 --- a/docs/api/modules/addons_progress.html +++ b/docs/api/modules/addons_progress.html @@ -1,3 +1,3 @@ -addons/progress | wretch

    Module addons/progress

    Index

    Interfaces

    ProgressResolver +addons/progress | wretch

    Generated using TypeDoc

    \ No newline at end of file diff --git a/docs/api/modules/addons_queryString.html b/docs/api/modules/addons_queryString.html index 700fa7f..9beb80b 100644 --- a/docs/api/modules/addons_queryString.html +++ b/docs/api/modules/addons_queryString.html @@ -1,3 +1,3 @@ -addons/queryString | wretch

    Module addons/queryString

    Index

    Interfaces

    QueryStringAddon +addons/queryString | wretch

    Generated using TypeDoc

    \ No newline at end of file diff --git a/docs/api/modules/index.default.html b/docs/api/modules/index.default.html index cf92137..515db9f 100644 --- a/docs/api/modules/index.default.html +++ b/docs/api/modules/index.default.html @@ -1,4 +1,4 @@ -default | wretch

    Namespace default

    Index

    Variables

    WretchError +default | wretch

    Namespace default

    Index

    Variables

    WretchError default errorType options diff --git a/docs/api/modules/index.html b/docs/api/modules/index.html index e5089f7..2e6107a 100644 --- a/docs/api/modules/index.html +++ b/docs/api/modules/index.html @@ -1,4 +1,4 @@ -index | wretch

    Module index

    Index

    Namespaces

    default +index | wretch

    Module index

    Index

    Namespaces

    Interfaces

    Wretch WretchError WretchResponseChain diff --git a/docs/api/modules/middlewares.html b/docs/api/modules/middlewares.html index 5d12046..c33344a 100644 --- a/docs/api/modules/middlewares.html +++ b/docs/api/modules/middlewares.html @@ -1,4 +1,4 @@ -middlewares | wretch

    Module middlewares

    References

    DedupeKeyFunction +middlewares | wretch

    Module middlewares

    References

    DedupeKeyFunction DedupeMiddleware DedupeOptions DedupeResolverFunction diff --git a/docs/api/modules/middlewares_dedupe.html b/docs/api/modules/middlewares_dedupe.html index eacac41..01dda24 100644 --- a/docs/api/modules/middlewares_dedupe.html +++ b/docs/api/modules/middlewares_dedupe.html @@ -1,4 +1,4 @@ -middlewares/dedupe | wretch

    Module middlewares/dedupe

    Index

    Type Aliases

    DedupeKeyFunction +middlewares/dedupe | wretch

    Module middlewares/dedupe

    Index

    Type Aliases

    DedupeKeyFunction DedupeMiddleware DedupeOptions DedupeResolverFunction diff --git a/docs/api/modules/middlewares_delay.html b/docs/api/modules/middlewares_delay.html index 860750c..ffeb279 100644 --- a/docs/api/modules/middlewares_delay.html +++ b/docs/api/modules/middlewares_delay.html @@ -1,3 +1,3 @@ -middlewares/delay | wretch

    Module middlewares/delay

    Index

    Type Aliases

    DelayMiddleware +middlewares/delay | wretch

    Generated using TypeDoc

    \ No newline at end of file diff --git a/docs/api/modules/middlewares_retry.html b/docs/api/modules/middlewares_retry.html index b353530..bde6d7f 100644 --- a/docs/api/modules/middlewares_retry.html +++ b/docs/api/modules/middlewares_retry.html @@ -1,4 +1,4 @@ -middlewares/retry | wretch

    Module middlewares/retry

    Index

    Type Aliases

    DelayRampFunction +middlewares/retry | wretch

    Module middlewares/retry

    Index

    Type Aliases

    DelayRampFunction OnRetryFunction OnRetryFunctionResponse RetryMiddleware diff --git a/docs/api/modules/middlewares_throttlingCache.html b/docs/api/modules/middlewares_throttlingCache.html index 94cf923..a4cb450 100644 --- a/docs/api/modules/middlewares_throttlingCache.html +++ b/docs/api/modules/middlewares_throttlingCache.html @@ -1,4 +1,4 @@ -middlewares/throttlingCache | wretch

    Module middlewares/throttlingCache

    Index

    Type Aliases

    ThrottlingCacheClearFunction +middlewares/throttlingCache | wretch

    Module middlewares/throttlingCache

    Index

    Type Aliases

    ThrottlingCacheClearFunction ThrottlingCacheConditionFunction ThrottlingCacheInvalidateFunction ThrottlingCacheKeyFunction diff --git a/docs/api/types/index.Config.html b/docs/api/types/index.Config.html index c047266..209c9a9 100644 --- a/docs/api/types/index.Config.html +++ b/docs/api/types/index.Config.html @@ -1,2 +1,2 @@ Config | wretch

    Type alias Config

    Config: {
        errorType: string;
        options: {};
        polyfills: {};
        polyfill(p, doThrow?, instance?, ...args) => any;
    }

    Configuration object.

    -

    Type declaration

    • errorType: string
    • options: {}
      • polyfills: {}
        • polyfill:function
          • Parameters

            • p: string
            • Optional doThrow: boolean
            • Optional instance: boolean
            • Rest ...args: any[]

            Returns any

        Generated using TypeDoc

        \ No newline at end of file +

        Type declaration

        • errorType: string
        • options: {}
          • polyfills: {}
            • polyfill:function
              • Parameters

                • p: string
                • Optional doThrow: boolean
                • Optional instance: boolean
                • Rest ...args: any[]

                Returns any

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/types/index.ConfiguredMiddleware.html b/docs/api/types/index.ConfiguredMiddleware.html index ca75e07..a8fa3f9 100644 --- a/docs/api/types/index.ConfiguredMiddleware.html +++ b/docs/api/types/index.ConfiguredMiddleware.html @@ -1,4 +1,4 @@ ConfiguredMiddleware | wretch

            Type alias ConfiguredMiddleware

            ConfiguredMiddleware: ((next) => FetchLike)

            Type declaration

              • (next): FetchLike
              • A ready to use middleware which is called before the request is sent. Input is the next middleware in the chain, then url and options. Output is a promise.

                -

                Parameters

                Returns FetchLike

            Generated using TypeDoc

            \ No newline at end of file +

            Parameters

            Returns FetchLike

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/types/index.FetchLike.html b/docs/api/types/index.FetchLike.html index 7cc20d4..8ec18a6 100644 --- a/docs/api/types/index.FetchLike.html +++ b/docs/api/types/index.FetchLike.html @@ -1,2 +1,2 @@ FetchLike | wretch

            Type alias FetchLike

            FetchLike: ((url, opts) => Promise<WretchResponse>)

            Type declaration

            Generated using TypeDoc

            \ No newline at end of file +

            Parameters

            Returns Promise<WretchResponse>

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/types/index.Middleware.html b/docs/api/types/index.Middleware.html index 02a25cb..0966c4b 100644 --- a/docs/api/types/index.Middleware.html +++ b/docs/api/types/index.Middleware.html @@ -1,3 +1,3 @@ Middleware | wretch

            Type alias Middleware

            Middleware: ((options?) => ConfiguredMiddleware)

            Type declaration

              • (options?): ConfiguredMiddleware
              • Shape of a typical middleware. Expects options and returns a ConfiguredMiddleware that can then be registered using the .middlewares function.

                -

                Parameters

                • Optional options: {
                      [key: string]: any;
                  }
                  • [key: string]: any

                Returns ConfiguredMiddleware

            Generated using TypeDoc

            \ No newline at end of file +

            Parameters

            • Optional options: {
                  [key: string]: any;
              }
              • [key: string]: any

            Returns ConfiguredMiddleware

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/types/index.WretchAddon.html b/docs/api/types/index.WretchAddon.html index 460f983..b7e4a5c 100644 --- a/docs/api/types/index.WretchAddon.html +++ b/docs/api/types/index.WretchAddon.html @@ -1,2 +1,2 @@ -WretchAddon | wretch

            Type alias WretchAddon<W, R>

            WretchAddon<W, R>: {
                resolver?: R;
                wretch?: W;
                beforeRequest?<T, C, R>(wretch, options, state) => T & Wretch<T, C, R>;
            }

            An addon enhancing either the request or response chain (or both).

            -

            Type Parameters

            • W extends unknown

            • R extends unknown = unknown

            Type declaration

            • Optional resolver?: R
            • Optional wretch?: W
            • beforeRequest?:function

            Generated using TypeDoc

            \ No newline at end of file +WretchAddon | wretch

            Type alias WretchAddon<W, R>

            WretchAddon<W, R>: {
                resolver?: R | (<T, C>(_) => R);
                wretch?: W;
                beforeRequest?<T, C, R>(wretch, options, state) => T & Wretch<T, C, R>;
            }

            An addon enhancing either the request or response chain (or both).

            +

            Type Parameters

            • W extends unknown

            • R extends unknown = unknown

            Type declaration

            • Optional resolver?: R | (<T, C>(_) => R)
            • Optional wretch?: W
            • beforeRequest?:function

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/types/index.WretchDeferredCallback.html b/docs/api/types/index.WretchDeferredCallback.html index 53b57bc..b6b39ef 100644 --- a/docs/api/types/index.WretchDeferredCallback.html +++ b/docs/api/types/index.WretchDeferredCallback.html @@ -1,2 +1,2 @@ WretchDeferredCallback | wretch

            Type alias WretchDeferredCallback<T, C, R>

            WretchDeferredCallback<T, C, R>: ((wretch, url, options) => Wretch<T, C, any>)

            Type Parameters

            • T

            • C

            • R

            Type declaration

              • (wretch, url, options): Wretch<T, C, any>
              • Callback provided to the defer function allowing to chain deferred actions that will be stored and applied just before the request is sent.

                -

                Parameters

                Returns Wretch<T, C, any>

            Generated using TypeDoc

            \ No newline at end of file +

            Parameters

            Returns Wretch<T, C, any>

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/types/index.WretchErrorCallback.html b/docs/api/types/index.WretchErrorCallback.html index a4201ac..1d36ceb 100644 --- a/docs/api/types/index.WretchErrorCallback.html +++ b/docs/api/types/index.WretchErrorCallback.html @@ -1,2 +1,2 @@ WretchErrorCallback | wretch

            Type alias WretchErrorCallback<T, C, R>

            WretchErrorCallback<T, C, R>: ((error, originalRequest) => any)

            Type Parameters

            • T

            • C

            • R

            Type declaration

              • (error, originalRequest): any
              • Callback provided to catchers on error. Contains the original wretch instance used to perform the request.

                -

                Parameters

                Returns any

            Generated using TypeDoc

            \ No newline at end of file +

            Parameters

            Returns any

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/types/index.WretchOptions.html b/docs/api/types/index.WretchOptions.html index f0162e4..1bc8206 100644 --- a/docs/api/types/index.WretchOptions.html +++ b/docs/api/types/index.WretchOptions.html @@ -1,2 +1,2 @@ WretchOptions | wretch

            Type alias WretchOptions

            WretchOptions: Record<string, any>

            Fetch Request options with additional properties.

            -

            Generated using TypeDoc

            \ No newline at end of file +

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/types/index.WretchResponse.html b/docs/api/types/index.WretchResponse.html index d2ffb8e..99401a5 100644 --- a/docs/api/types/index.WretchResponse.html +++ b/docs/api/types/index.WretchResponse.html @@ -1,2 +1,2 @@ WretchResponse | wretch

            Type alias WretchResponse

            WretchResponse: Response & {
                [key: string]: any;
            }

            Fetch Response object with additional properties.

            -

            Type declaration

            • [key: string]: any

            Generated using TypeDoc

            \ No newline at end of file +

            Type declaration

            • [key: string]: any

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/types/middlewares_dedupe.DedupeKeyFunction.html b/docs/api/types/middlewares_dedupe.DedupeKeyFunction.html index bec2252..c0566b4 100644 --- a/docs/api/types/middlewares_dedupe.DedupeKeyFunction.html +++ b/docs/api/types/middlewares_dedupe.DedupeKeyFunction.html @@ -1 +1 @@ -DedupeKeyFunction | wretch

            Type alias DedupeKeyFunction

            DedupeKeyFunction: ((url, opts) => string)

            Type declaration

              • (url, opts): string
              • Parameters

                Returns string

            Generated using TypeDoc

            \ No newline at end of file +DedupeKeyFunction | wretch

            Type alias DedupeKeyFunction

            DedupeKeyFunction: ((url, opts) => string)

            Type declaration

              • (url, opts): string
              • Parameters

                Returns string

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/types/middlewares_dedupe.DedupeMiddleware.html b/docs/api/types/middlewares_dedupe.DedupeMiddleware.html index 9f5eff3..51e2600 100644 --- a/docs/api/types/middlewares_dedupe.DedupeMiddleware.html +++ b/docs/api/types/middlewares_dedupe.DedupeMiddleware.html @@ -18,4 +18,4 @@

            This function is called when resolving the fetch response from duplicate calls. By default it clones the response to allow reading the body from multiple sources.

            -

            Parameters

            Returns ConfiguredMiddleware

            Generated using TypeDoc

            \ No newline at end of file +

            Parameters

            Returns ConfiguredMiddleware

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/types/middlewares_dedupe.DedupeOptions.html b/docs/api/types/middlewares_dedupe.DedupeOptions.html index a1e4ced..8e91d58 100644 --- a/docs/api/types/middlewares_dedupe.DedupeOptions.html +++ b/docs/api/types/middlewares_dedupe.DedupeOptions.html @@ -1 +1 @@ -DedupeOptions | wretch
            DedupeOptions: {
                key?: DedupeKeyFunction;
                resolver?: DedupeResolverFunction;
                skip?: DedupeSkipFunction;
            }

            Type declaration

            Generated using TypeDoc

            \ No newline at end of file +DedupeOptions | wretch
            DedupeOptions: {
                key?: DedupeKeyFunction;
                resolver?: DedupeResolverFunction;
                skip?: DedupeSkipFunction;
            }

            Type declaration

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/types/middlewares_dedupe.DedupeResolverFunction.html b/docs/api/types/middlewares_dedupe.DedupeResolverFunction.html index a7377ae..3f6f32d 100644 --- a/docs/api/types/middlewares_dedupe.DedupeResolverFunction.html +++ b/docs/api/types/middlewares_dedupe.DedupeResolverFunction.html @@ -1 +1 @@ -DedupeResolverFunction | wretch

            Type alias DedupeResolverFunction

            DedupeResolverFunction: ((response) => Response)

            Type declaration

              • (response): Response
              • Parameters

                • response: Response

                Returns Response

            Generated using TypeDoc

            \ No newline at end of file +DedupeResolverFunction | wretch

            Type alias DedupeResolverFunction

            DedupeResolverFunction: ((response) => Response)

            Type declaration

              • (response): Response
              • Parameters

                • response: Response

                Returns Response

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/types/middlewares_dedupe.DedupeSkipFunction.html b/docs/api/types/middlewares_dedupe.DedupeSkipFunction.html index 221b635..73d0094 100644 --- a/docs/api/types/middlewares_dedupe.DedupeSkipFunction.html +++ b/docs/api/types/middlewares_dedupe.DedupeSkipFunction.html @@ -1 +1 @@ -DedupeSkipFunction | wretch

            Type alias DedupeSkipFunction

            DedupeSkipFunction: ((url, opts) => boolean)

            Type declaration

              • (url, opts): boolean
              • Parameters

                Returns boolean

            Generated using TypeDoc

            \ No newline at end of file +DedupeSkipFunction | wretch

            Type alias DedupeSkipFunction

            DedupeSkipFunction: ((url, opts) => boolean)

            Type declaration

              • (url, opts): boolean
              • Parameters

                Returns boolean

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/types/middlewares_delay.DelayMiddleware.html b/docs/api/types/middlewares_delay.DelayMiddleware.html index 899d8aa..981f189 100644 --- a/docs/api/types/middlewares_delay.DelayMiddleware.html +++ b/docs/api/types/middlewares_delay.DelayMiddleware.html @@ -5,4 +5,4 @@

            The request will be delayed by that amount of time.

            -

            Parameters

            • time: number

            Returns ConfiguredMiddleware

            Generated using TypeDoc

            \ No newline at end of file +

            Parameters

            • time: number

            Returns ConfiguredMiddleware

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/types/middlewares_retry.DelayRampFunction.html b/docs/api/types/middlewares_retry.DelayRampFunction.html index 0d081a1..fb2cf58 100644 --- a/docs/api/types/middlewares_retry.DelayRampFunction.html +++ b/docs/api/types/middlewares_retry.DelayRampFunction.html @@ -1 +1 @@ -DelayRampFunction | wretch

            Type alias DelayRampFunction

            DelayRampFunction: ((delay, nbOfAttempts) => number)

            Type declaration

              • (delay, nbOfAttempts): number
              • Parameters

                • delay: number
                • nbOfAttempts: number

                Returns number

            Generated using TypeDoc

            \ No newline at end of file +DelayRampFunction | wretch

            Type alias DelayRampFunction

            DelayRampFunction: ((delay, nbOfAttempts) => number)

            Type declaration

              • (delay, nbOfAttempts): number
              • Parameters

                • delay: number
                • nbOfAttempts: number

                Returns number

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/types/middlewares_retry.OnRetryFunction.html b/docs/api/types/middlewares_retry.OnRetryFunction.html index 4197f53..b92add9 100644 --- a/docs/api/types/middlewares_retry.OnRetryFunction.html +++ b/docs/api/types/middlewares_retry.OnRetryFunction.html @@ -1 +1 @@ -OnRetryFunction | wretch

            Type alias OnRetryFunction

            OnRetryFunction: ((args) => void | OnRetryFunctionResponse | Promise<OnRetryFunctionResponse>)

            Type declaration

            Generated using TypeDoc

            \ No newline at end of file +OnRetryFunction | wretch

            Type alias OnRetryFunction

            OnRetryFunction: ((args) => void | OnRetryFunctionResponse | Promise<OnRetryFunctionResponse>)

            Type declaration

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/types/middlewares_retry.OnRetryFunctionResponse.html b/docs/api/types/middlewares_retry.OnRetryFunctionResponse.html index 7b511d1..370ab8f 100644 --- a/docs/api/types/middlewares_retry.OnRetryFunctionResponse.html +++ b/docs/api/types/middlewares_retry.OnRetryFunctionResponse.html @@ -1 +1 @@ -OnRetryFunctionResponse | wretch

            Type alias OnRetryFunctionResponse

            OnRetryFunctionResponse: {
                options?: WretchOptions;
                url?: string;
            } | undefined

            Type declaration

            Generated using TypeDoc

            \ No newline at end of file +OnRetryFunctionResponse | wretch

            Type alias OnRetryFunctionResponse

            OnRetryFunctionResponse: {
                options?: WretchOptions;
                url?: string;
            } | undefined

            Type declaration

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/types/middlewares_retry.RetryMiddleware.html b/docs/api/types/middlewares_retry.RetryMiddleware.html index 3d1be8d..fd550df 100644 --- a/docs/api/types/middlewares_retry.RetryMiddleware.html +++ b/docs/api/types/middlewares_retry.RetryMiddleware.html @@ -5,4 +5,4 @@
            import wretch from 'wretch'
            import { retry } from 'wretch/middlewares'

            wretch().middlewares([
            retry({
            // Options - defaults below
            delayTimer: 500,
            delayRamp: (delay, nbOfAttempts) => delay * nbOfAttempts,
            maxAttempts: 10,
            until: (response, error) => response && response.ok,
            onRetry: null,
            retryOnNetworkError: false,
            resolveWithLatestResponse: false,
            skip: undefined
            })
            ])

            // You can also return a Promise, which is useful if you want to inspect the body:
            wretch().middlewares([
            retry({
            until: response =>
            response.clone().json().then(body =>
            body.field === 'something'
            )
            })
            ])
            -

            Parameters

            Returns ConfiguredMiddleware

            Generated using TypeDoc

            \ No newline at end of file +

            Parameters

            Returns ConfiguredMiddleware

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/types/middlewares_retry.RetryOptions.html b/docs/api/types/middlewares_retry.RetryOptions.html index 0283a7f..c34e317 100644 --- a/docs/api/types/middlewares_retry.RetryOptions.html +++ b/docs/api/types/middlewares_retry.RetryOptions.html @@ -17,4 +17,4 @@

            Default: undefined

          • Optional until?: UntilFunction

            The request will be retried until that condition is satisfied.

            Default: response && response.ok

            -
          • Generated using TypeDoc

            \ No newline at end of file +

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/types/middlewares_retry.SkipFunction.html b/docs/api/types/middlewares_retry.SkipFunction.html index 0abb7b1..b365a6c 100644 --- a/docs/api/types/middlewares_retry.SkipFunction.html +++ b/docs/api/types/middlewares_retry.SkipFunction.html @@ -1 +1 @@ -SkipFunction | wretch
            SkipFunction: ((url, opts) => boolean)

            Type declaration

              • (url, opts): boolean
              • Parameters

                Returns boolean

            Generated using TypeDoc

            \ No newline at end of file +SkipFunction | wretch
            SkipFunction: ((url, opts) => boolean)

            Type declaration

              • (url, opts): boolean
              • Parameters

                Returns boolean

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/types/middlewares_retry.UntilFunction.html b/docs/api/types/middlewares_retry.UntilFunction.html index cf04aee..54c0be7 100644 --- a/docs/api/types/middlewares_retry.UntilFunction.html +++ b/docs/api/types/middlewares_retry.UntilFunction.html @@ -1 +1 @@ -UntilFunction | wretch

            Type alias UntilFunction

            UntilFunction: ((response?, error?) => boolean | Promise<boolean>)

            Type declaration

              • (response?, error?): boolean | Promise<boolean>
              • Parameters

                • Optional response: Response
                • Optional error: Error

                Returns boolean | Promise<boolean>

            Generated using TypeDoc

            \ No newline at end of file +UntilFunction | wretch

            Type alias UntilFunction

            UntilFunction: ((response?, error?) => boolean | Promise<boolean>)

            Type declaration

              • (response?, error?): boolean | Promise<boolean>
              • Parameters

                • Optional response: Response
                • Optional error: Error

                Returns boolean | Promise<boolean>

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/types/middlewares_throttlingCache.ThrottlingCacheClearFunction.html b/docs/api/types/middlewares_throttlingCache.ThrottlingCacheClearFunction.html index 01d44e2..960fa56 100644 --- a/docs/api/types/middlewares_throttlingCache.ThrottlingCacheClearFunction.html +++ b/docs/api/types/middlewares_throttlingCache.ThrottlingCacheClearFunction.html @@ -1 +1 @@ -ThrottlingCacheClearFunction | wretch
            ThrottlingCacheClearFunction: ((url, opts) => boolean)

            Type declaration

              • (url, opts): boolean
              • Parameters

                Returns boolean

            Generated using TypeDoc

            \ No newline at end of file +ThrottlingCacheClearFunction | wretch
            ThrottlingCacheClearFunction: ((url, opts) => boolean)

            Type declaration

              • (url, opts): boolean
              • Parameters

                Returns boolean

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/types/middlewares_throttlingCache.ThrottlingCacheConditionFunction.html b/docs/api/types/middlewares_throttlingCache.ThrottlingCacheConditionFunction.html index 75b461a..38bdeb0 100644 --- a/docs/api/types/middlewares_throttlingCache.ThrottlingCacheConditionFunction.html +++ b/docs/api/types/middlewares_throttlingCache.ThrottlingCacheConditionFunction.html @@ -1 +1 @@ -ThrottlingCacheConditionFunction | wretch
            ThrottlingCacheConditionFunction: ((response) => boolean)

            Type declaration

              • (response): boolean
              • Parameters

                Returns boolean

            Generated using TypeDoc

            \ No newline at end of file +ThrottlingCacheConditionFunction | wretch
            ThrottlingCacheConditionFunction: ((response) => boolean)

            Type declaration

              • (response): boolean
              • Parameters

                Returns boolean

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/types/middlewares_throttlingCache.ThrottlingCacheInvalidateFunction.html b/docs/api/types/middlewares_throttlingCache.ThrottlingCacheInvalidateFunction.html index 9ef8f02..403fd8f 100644 --- a/docs/api/types/middlewares_throttlingCache.ThrottlingCacheInvalidateFunction.html +++ b/docs/api/types/middlewares_throttlingCache.ThrottlingCacheInvalidateFunction.html @@ -1 +1 @@ -ThrottlingCacheInvalidateFunction | wretch

            Type alias ThrottlingCacheInvalidateFunction

            ThrottlingCacheInvalidateFunction: ((url, opts) => string | RegExp | void)

            Type declaration

              • (url, opts): string | RegExp | void
              • Parameters

                Returns string | RegExp | void

            Generated using TypeDoc

            \ No newline at end of file +ThrottlingCacheInvalidateFunction | wretch

            Type alias ThrottlingCacheInvalidateFunction

            ThrottlingCacheInvalidateFunction: ((url, opts) => string | RegExp | void)

            Type declaration

              • (url, opts): string | RegExp | void
              • Parameters

                Returns string | RegExp | void

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/types/middlewares_throttlingCache.ThrottlingCacheKeyFunction.html b/docs/api/types/middlewares_throttlingCache.ThrottlingCacheKeyFunction.html index 98eb3f8..6b22d74 100644 --- a/docs/api/types/middlewares_throttlingCache.ThrottlingCacheKeyFunction.html +++ b/docs/api/types/middlewares_throttlingCache.ThrottlingCacheKeyFunction.html @@ -1 +1 @@ -ThrottlingCacheKeyFunction | wretch
            ThrottlingCacheKeyFunction: ((url, opts) => string)

            Type declaration

              • (url, opts): string
              • Parameters

                Returns string

            Generated using TypeDoc

            \ No newline at end of file +ThrottlingCacheKeyFunction | wretch
            ThrottlingCacheKeyFunction: ((url, opts) => string)

            Type declaration

              • (url, opts): string
              • Parameters

                Returns string

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/types/middlewares_throttlingCache.ThrottlingCacheMiddleware.html b/docs/api/types/middlewares_throttlingCache.ThrottlingCacheMiddleware.html index 78565a1..26219a5 100644 --- a/docs/api/types/middlewares_throttlingCache.ThrottlingCacheMiddleware.html +++ b/docs/api/types/middlewares_throttlingCache.ThrottlingCacheMiddleware.html @@ -41,4 +41,4 @@

            If set, a Response returned from the cache whill be flagged with a property name equal to this option.

            -

            Parameters

            Returns ConfiguredMiddleware & {
                cache: Map<any, any>;
                inflight: Map<any, any>;
                throttling: Set<unknown>;
                cacheResponse(key, response) => void;
            }

            Generated using TypeDoc

            \ No newline at end of file +

            Parameters

            Returns ConfiguredMiddleware & {
                cache: Map<any, any>;
                inflight: Map<any, any>;
                throttling: Set<unknown>;
                cacheResponse(key, response) => void;
            }

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/types/middlewares_throttlingCache.ThrottlingCacheOptions.html b/docs/api/types/middlewares_throttlingCache.ThrottlingCacheOptions.html index e3c4bba..6cec5a8 100644 --- a/docs/api/types/middlewares_throttlingCache.ThrottlingCacheOptions.html +++ b/docs/api/types/middlewares_throttlingCache.ThrottlingCacheOptions.html @@ -1 +1 @@ -ThrottlingCacheOptions | wretch
            ThrottlingCacheOptions: {
                clear?: ThrottlingCacheClearFunction;
                condition?: ThrottlingCacheConditionFunction;
                flagResponseOnCacheHit?: string;
                invalidate?: ThrottlingCacheInvalidateFunction;
                key?: ThrottlingCacheKeyFunction;
                skip?: ThrottlingCacheSkipFunction;
                throttle?: number;
            }

            Type declaration

            Generated using TypeDoc

            \ No newline at end of file +ThrottlingCacheOptions | wretch
            ThrottlingCacheOptions: {
                clear?: ThrottlingCacheClearFunction;
                condition?: ThrottlingCacheConditionFunction;
                flagResponseOnCacheHit?: string;
                invalidate?: ThrottlingCacheInvalidateFunction;
                key?: ThrottlingCacheKeyFunction;
                skip?: ThrottlingCacheSkipFunction;
                throttle?: number;
            }

            Type declaration

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/types/middlewares_throttlingCache.ThrottlingCacheSkipFunction.html b/docs/api/types/middlewares_throttlingCache.ThrottlingCacheSkipFunction.html index a9eba7d..fcb5568 100644 --- a/docs/api/types/middlewares_throttlingCache.ThrottlingCacheSkipFunction.html +++ b/docs/api/types/middlewares_throttlingCache.ThrottlingCacheSkipFunction.html @@ -1 +1 @@ -ThrottlingCacheSkipFunction | wretch
            ThrottlingCacheSkipFunction: ((url, opts) => boolean)

            Type declaration

              • (url, opts): boolean
              • Parameters

                Returns boolean

            Generated using TypeDoc

            \ No newline at end of file +ThrottlingCacheSkipFunction | wretch
            ThrottlingCacheSkipFunction: ((url, opts) => boolean)

            Type declaration

              • (url, opts): boolean
              • Parameters

                Returns boolean

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/variables/addons_formData.default.html b/docs/api/variables/addons_formData.default.html index bbde3c3..46d542b 100644 --- a/docs/api/variables/addons_formData.default.html +++ b/docs/api/variables/addons_formData.default.html @@ -1,4 +1,4 @@ default | wretch

            Variable defaultConst

            default: WretchAddon<FormDataAddon> = ...

            Adds the ability to convert a an object to a FormData and use it as a request body.

            import FormDataAddon from "wretch/addons/formData"

            wretch().addon(FormDataAddon)
            -

            Generated using TypeDoc

            \ No newline at end of file +

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/variables/addons_formUrl.default.html b/docs/api/variables/addons_formUrl.default.html index 45912ea..2e97f7f 100644 --- a/docs/api/variables/addons_formUrl.default.html +++ b/docs/api/variables/addons_formUrl.default.html @@ -1,4 +1,4 @@ default | wretch

            Variable defaultConst

            default: WretchAddon<FormUrlAddon> = ...

            Adds the ability to convert a an object to a FormUrl and use it as a request body.

            import FormUrlAddon from "wretch/addons/formUrl"

            wretch().addon(FormUrlAddon)
            -

            Generated using TypeDoc

            \ No newline at end of file +

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/variables/addons_queryString.default.html b/docs/api/variables/addons_queryString.default.html index b6ddd58..df159d2 100644 --- a/docs/api/variables/addons_queryString.default.html +++ b/docs/api/variables/addons_queryString.default.html @@ -1,4 +1,4 @@ default | wretch

            Variable defaultConst

            Adds the ability to append query parameters from a javascript object.

            import QueryAddon from "wretch/addons/queryString"

            wretch().addon(QueryAddon)
            -

            Generated using TypeDoc

            \ No newline at end of file +

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/variables/index.default.WretchError.html b/docs/api/variables/index.default.WretchError.html index d626ce0..5bd92ad 100644 --- a/docs/api/variables/index.default.WretchError.html +++ b/docs/api/variables/index.default.WretchError.html @@ -1 +1 @@ -WretchError | wretch

            Variable WretchError

            WretchError: typeof WretchError

            Generated using TypeDoc

            \ No newline at end of file +WretchError | wretch

            Variable WretchError

            WretchError: typeof WretchError

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/variables/index.default.default.html b/docs/api/variables/index.default.default.html index 4c8fdce..13b4a73 100644 --- a/docs/api/variables/index.default.default.html +++ b/docs/api/variables/index.default.default.html @@ -1 +1 @@ -default | wretch
            default: typeof default

            Generated using TypeDoc

            \ No newline at end of file +default | wretch
            default: typeof default

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/variables/index.default.errorType.html b/docs/api/variables/index.default.errorType.html index e941558..72ae9d9 100644 --- a/docs/api/variables/index.default.errorType.html +++ b/docs/api/variables/index.default.errorType.html @@ -1,2 +1,2 @@ errorType | wretch

            Variable errorType

            errorType: ((errorType) => void)

            Type declaration

              • (errorType): void
              • {@inheritDoc setErrorType}

                -

                Parameters

                • errorType: string

                Returns void

            Generated using TypeDoc

            \ No newline at end of file +

            Parameters

            Returns void

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/variables/index.default.options.html b/docs/api/variables/index.default.options.html index 6482bf0..b994cb6 100644 --- a/docs/api/variables/index.default.options.html +++ b/docs/api/variables/index.default.options.html @@ -1,2 +1,2 @@ options | wretch
            options: ((options, replace?) => void)

            Type declaration

              • (options, replace?): void
              • {@inheritDoc setOptions}

                -

                Parameters

                • options: object
                • replace: boolean = false

                Returns void

            Generated using TypeDoc

            \ No newline at end of file +

            Parameters

            Returns void

            Generated using TypeDoc

            \ No newline at end of file diff --git a/docs/api/variables/index.default.polyfills.html b/docs/api/variables/index.default.polyfills.html index a3c8ef2..19d1611 100644 --- a/docs/api/variables/index.default.polyfills.html +++ b/docs/api/variables/index.default.polyfills.html @@ -1,2 +1,2 @@ polyfills | wretch

            Variable polyfills

            polyfills: ((polyfills, replace?) => void)

            Type declaration

              • (polyfills, replace?): void
              • {@inheritDoc setPolyfills}

                -

                Parameters

                • polyfills: object
                • replace: boolean = false

                Returns void

            Generated using TypeDoc

            \ No newline at end of file +

            Parameters

            Returns void

            Generated using TypeDoc

            \ No newline at end of file diff --git a/package.json b/package.json index 8f275bf..ddc9e0b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wretch", - "version": "2.7.1", + "version": "2.8.0", "type": "module", "description": "A tiny wrapper built around fetch with an intuitive syntax.", "keywords": [