@theintern/common
Version:
Common modules used by @theintern projects
41 lines (40 loc) • 1.16 kB
TypeScript
import { CancellablePromise } from './Task';
export declare type RequestMethod = 'delete' | 'DELETE' | 'get' | 'GET' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT';
export interface RequestOptions {
data?: any;
followRedirects?: boolean;
handleAs?: 'text' | 'json';
headers?: {
[key: string]: string | number;
};
method?: RequestMethod;
password?: string;
query?: string | {
[key: string]: any;
};
proxy?: string;
user?: string;
username?: string;
onDownloadProgress?: (progressEvent: any) => void;
}
export interface ProgressEvent {
total: number;
bytes: number;
[index: string]: any;
}
export interface Headers {
all: {
[key: string]: string;
};
get(key: string): string;
}
export interface Response {
headers: Headers;
ok: boolean;
status: number;
statusText: string;
arrayBuffer(): CancellablePromise<ArrayBuffer>;
json<R = object>(): CancellablePromise<R>;
text(): CancellablePromise<string>;
}
export default function request(url: string, options?: RequestOptions): CancellablePromise<Response>;