UNPKG

react-antd-admin-panel

Version:

Modern TypeScript-first React admin panel builder with Ant Design 6

87 lines 2.26 kB
import { AxiosInstance } from 'axios'; import type { RequestConfig } from '../types'; /** * Post Model - Type-safe HTTP POST/PUT/DELETE/PATCH request builder * @template TBody - Request body type * @template TResponse - Response data type */ export declare class Post<TBody = any, TResponse = any> { private _target?; private _method; private _body?; private _params; private _headers; private _config; private _hooks; private _abortController?; private static _axios; /** * Set the request target URL */ target(url: string): this; /** * Set the HTTP method */ method(method: 'POST' | 'PUT' | 'DELETE' | 'PATCH'): this; /** * Set the request body */ body(data: TBody): this; /** * Set URL parameters */ params(params: Record<string, any>): this; /** * Set a single URL parameter */ param(key: string, value: any): this; /** * Set request headers */ headers(headers: Record<string, string>): this; /** * Set a single header */ header(key: string, value: string): this; /** * Set additional request configuration */ config(config: Partial<RequestConfig>): this; /** * Hook called before the request is sent */ onBefore(callback: (config: RequestConfig) => RequestConfig | Promise<RequestConfig>): this; /** * Hook called when request succeeds */ onThen(callback: (data: TResponse) => void | Promise<void>): this; /** * Hook called when request fails */ onCatch(callback: (error: Error) => any): this; /** * Hook called after request completes (success or failure) */ onFinally(callback: () => void | Promise<void>): this; /** * Execute the request */ execute(): Promise<TResponse>; /** * Cancel the request */ cancel(message?: string): void; /** * Set global axios instance */ static setAxios(instance: AxiosInstance): void; /** * Get the current axios instance */ static getAxios(): AxiosInstance; /** * Configure global defaults */ static configure(config: RequestConfig): void; } //# sourceMappingURL=Post.d.ts.map