@wisdomgarden/cloak-plugin-http
Version:
Making native HTTP requests within Cloak applications.
35 lines (28 loc) • 816 B
TypeScript
import { Plugin, ESObject, CloakPlugins } from "@wisdomgarden/cloak";
interface RequestOptions {
method: 'get' | 'post' | 'put' | 'head' | 'delete' | 'options';
data?: ESObject;
params?: { [key: string]: string | number };
timeout?: number;
headers?: { [key: string]: string };
serializer?: 'json' | 'urlencoded';
responseType?: 'text' | 'json';
}
interface HTTPResponse {
status: number;
headers: { [key: string]: string };
url: string;
data?: ESObject;
error?: ESObject;
message?: string;
}
export interface HttpPlugin extends Plugin {
sendRequest(url: string, options?: RequestOptions): Promise<HTTPResponse>;
}
export const register: () => void;
export const Http: HttpPlugin;
declare module "@wisdomgarden/cloak" {
export interface CloakPlugins {
Http: HttpPlugin;
}
}