portals
Version:
Client-side HTTP requests with middleware support.
13 lines (12 loc) • 687 B
TypeScript
import { Request, Middleware } from ".";
export declare type GetToken<Req> = (request: Req) => void | null | string;
/**
* Adds the Authorization header with the returned string as the header value.
* Won't set the Authorization token if the result from getToken is falsey.
*/
export declare function withAuthorization<Req extends Request = Request>(getToken: GetToken<Req>, prefix?: string): Middleware;
/**
* Adds the Authorization header with the returned string as the bearer token.
* Won't set the Authorization token if the result from getToken is falsey.
*/
export declare function withBearer<Req extends Request = Request>(getToken: GetToken<Req>): Middleware;