BasicAuthAddon | wretch
interface BasicAuthAddon {
basicAuth<T extends BasicAuthAddon, C, R, E>(
this: T & Wretch<T, C, R, E>,
username: string,
password: string,
): this;
}
Methods
basicAuth
basicAuth<T extends BasicAuthAddon, C, R, E>(
this: T & Wretch<T, C, R, E>,
username: string,
password: string,
): thisSets the
Authorizationheader toBasic+ . 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
- T extends BasicAuthAddon
- C
- R
- E
Parameters
Returns this