kea-react
Version:
Componentes comunes de react
33 lines (32 loc) • 2.44 kB
TypeScript
import { UrlParameters } from "./url";
/**Una petición HTTP */
export interface HttpRequest {
/**URL de la petición */
url: string;
/**Metodo de la petición */
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
body?: any;
urlParameters?: UrlParameters<string>;
headers?: UrlParameters<string>;
}
/**Servicio de HTTP */
export declare class HttpClass {
/**Función de middleware que transforma todas las peticiones HTTP. Si es null el middleware no hara ninguna modificación a la petición. Asignela para aplicar sus propios middleware */
Middleware: (request: HttpRequest) => (PromiseLike<HttpRequest> | HttpRequest);
/**Perform an http GET. The promise returns the deserialized response body */
Get: <TParams extends UrlParameters<keyof TParams>, THeaderParams extends UrlParameters<keyof THeaderParams>>(url: string, parameters?: TParams | undefined, headers?: THeaderParams | undefined) => Promise<any>;
/**Perform an http DELETE. The promise returns the deserialized response body */
Delete<TParams extends UrlParameters<keyof TParams>, THeaderParams extends UrlParameters<keyof THeaderParams>>(url: string, parameters?: TParams, headers?: THeaderParams): Promise<any>;
/**Perform an http POST. The promise returns the deserialized response body */
Post<TParams extends UrlParameters<keyof TParams>, THeaderParams extends UrlParameters<keyof THeaderParams>>(url: string, body: any, parameters?: TParams, headers?: THeaderParams): Promise<any>;
/**Perform an http PUT. The promise returns the deserialized response body */
Put<TParams extends UrlParameters<keyof TParams>, THeaderParams extends UrlParameters<keyof THeaderParams>>(url: string, body: any, parameters?: TParams, headers?: THeaderParams): Promise<any>;
/**Serialize the body if any and execute an http request. The promise returns the http deserialized json body or a failure with the http status. Returns null if the body response was empty */
HttpJson(request: HttpRequest): Promise<any>;
/**Execute an http request. The promise returns the http body as-is or a failure with the http status */
Http(request: HttpRequest): Promise<any>;
/**Execute an http request. The promise returns the http body as-is or a failure with the http status */
private HttpNoMiddleware(request);
}
/**Servicio HTTP por default */
export declare var Http: HttpClass;