Variable polyfills

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

Type declaration

    • (polyfills: object, replace?: boolean): void
    • Sets the default polyfills that will be stored internally when instantiating wretch objects. Useful for browserless environments like node.js.

      Needed for libraries like fetch-ponyfill.

      import wretch from "wretch"

      wretch.polyfills({
      fetch: require("node-fetch"),
      FormData: require("form-data"),
      URLSearchParams: require("url").URLSearchParams,
      });

      // Uses the above polyfills.
      wretch("...").get().res();

      Parameters

      • polyfills: object

        An object containing the polyfills

      • replace: boolean = false

        If true, replaces the current polyfills instead of mixing in

      Returns void

Generated using TypeDoc