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

28 lines
970 B
TypeScript
Raw Normal View History

2020-01-03 14:44:51 +08:00
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 {
2020-04-28 10:17:14 +08:00
data: string;
2020-01-03 14:44:51 +08:00
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>;
};