Interface BasicAuthAddon

interface BasicAuthAddon {
    basicAuth<T, C, R>(this: T & Wretch<T, C, R>, username: string, password: string): this;
}

Methods

Methods

  • Sets the Authorization header to Basic + . Additionally, allows using URLs with credentials in them.

    const user = "user"
    const pass = "pass"

    // Automatically sets the Authorization header to "Basic " + <base64 encoded credentials>
    wretch("...").addon(BasicAuthAddon).basicAuth(user, pass).get()

    // Allows using URLs with credentials in them
    wretch(`https://${user}:${pass}@...`).addon(BasicAuthAddon).get()

    Type Parameters

    Parameters

    • this: T & Wretch<T, C, R>
    • username: string

      Username to use for basic auth

    • password: string

      Password to use for basic auth

    Returns this