Client
Example
import { Client, setDefaultClient } from "@olenbetong/appframe-data";
let client = new Client("synergi.olenbetong.no");
await client.login(process.env.APPFRAME_USER, process.env.APPFRAME_PWD);
setDefaultClient(client);API
export declare type LoginOptions = {
remember?: boolean;
};
export declare class Client {
private __hostname;
get hostname(): string;
constructor(hostname?: string);
getRequestUrl(path: string): string;
/**
* Wraps fetch and adds JSON headers (Accept and Content-Type) and X-Requested-With
* which is required by some handlers. If timeout is set in `init`, the request will
* be aborted if not finished by the amount of milliseconds set.
*
* If Content-Type should not be JSON, either pass in another Content-Type, or set
* isJson to false in `init`
*/
afFetch(url: string, init: RequestInit & {
timeout?: number;
isJson?: boolean;
}): Promise<Response>;
fetch(input: any, init?: any): Promise<Response>;
login(username: string, password: string, options?: LoginOptions): Promise<any>;
setHostname(hostname?: string): void;
}
export declare function getDefaultClient(): Client;
export declare function setDefaultClient(client: Client): void;Last updated
Was this helpful?