wretch
    Preparing search index...

    Variable progressAddonConst

    progressAddon: (
        options?: {
            getUploadTotal?: (
                url: string,
                opts: WretchOptions,
            ) => number | Promise<number>;
        },
    ) => WretchAddon<ProgressAddon, ProgressResolver> = ...

    Adds the ability to monitor progress when downloading a response.

    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)}%`))

    Type Declaration

      • (
            options?: {
                getUploadTotal?: (
                    url: string,
                    opts: WretchOptions,
                ) => number | Promise<number>;
            },
        ): WretchAddon<ProgressAddon, ProgressResolver>
      • Parameters

        • Optionaloptions: {
              getUploadTotal?: (
                  url: string,
                  opts: WretchOptions,
              ) => number | Promise<number>;
          }
          • OptionalgetUploadTotal?: (url: string, opts: WretchOptions) => number | Promise<number>

            Function used to determine the total upload size before streaming the request body. Receives the final request URL and options, returns the total byte size (sync or async). Defaults to trying the byteLength property for ArrayBuffer and the .size property for Blob (e.g., FormData or File), then falling back to Request#blob() when available.

            Note: The fallback of using Request#blob() is memory consuming as it loads the entire body into memory.

        Returns WretchAddon<ProgressAddon, ProgressResolver>