This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/doric-js/lib/src/native/network.d.ts
2020-04-28 10:18:16 +08:00

28 lines
970 B
TypeScript

import { BridgeContext } from "../runtime/global";
export interface IRequest {
url?: string;
method?: "get" | "post" | "put" | "delete";
headers?: {
[index: string]: string;
};
params?: {
[index: string]: string;
};
data?: object | string;
timeout?: number;
}
export interface IResponse {
data: string;
status: number;
headers?: {
[index: string]: string;
};
}
export declare function network(context: BridgeContext): {
request: (config: IRequest) => Promise<IResponse>;
get: (url: string, config?: IRequest | undefined) => Promise<IResponse>;
post: (url: string, data?: string | object | undefined, config?: IRequest | undefined) => Promise<IResponse>;
put: (url: string, data?: string | object | undefined, config?: IRequest | undefined) => Promise<IResponse>;
delete: (url: string, data?: string | object | undefined, config?: IRequest | undefined) => Promise<IResponse>;
};