XRequestRequest
XRequest
Request
type XRequestFunction<Input = Record<PropertyKey, any>, Output = Record<string, string>> = (baseURL: string,options: XRequestOptions<Input, Output>,) => XRequestClass<Input, Output>;
Property | Description | Type | Default | Version |
---|---|---|---|---|
baseURL | API endpoint URL | string | - | - |
options | Request options | XRequestOptions<Input, Output> | - | - |
Property | Description | Type | Default | Version |
---|---|---|---|---|
callbacks | Request callback handlers | XRequestCallbacks<Output> | - | - |
params | Request parameters | Input | - | - |
headers | Additional request headers | Record<string, string> | - | - |
timeout | Request timeout in milliseconds | number | - | - |
streamTimeout | Stream mode data timeout in milliseconds | number | - | - |
fetch | Custom fetch object | typeof fetch | - | - |
middlewares | Middlewares for pre- and post-request processing | XFetchMiddlewares | - | - |
transformStream | Stream processor | XStreamOptions<Output>['transformStream'] | ((baseURL: string, responseHeaders: Headers) => XStreamOptions<Output>['transformStream']) | - | - |
manual | Whether to manually control request sending. When true , need to manually call run method | boolean | false | - |
Property | Description | Type | Default | Version |
---|---|---|---|---|
onSuccess | Success callback | (chunks: Output[]) => void | - | - |
onError | Error handling callback | (error: Error) => void | - | - |
onUpdate | Message update callback | (chunk: Output) => void | - | - |
Property | Description | Type | Default | Version |
---|---|---|---|---|
abort | Cancel request | () => void | - | - |
run | Manually execute request (effective when manual=true ) | (params?: Input) => void | - | - |
isRequesting | Whether currently requesting | boolean | - | - |
type setXRequestGlobalOptions<Input, Output> = (options: XRequestGlobalOptions<Input, Output>,) => void;
type XRequestGlobalOptions<Input, Output> = Pick<XRequestOptions<Input, Output>,'headers' | 'timeout' | 'streamTimeout' | 'middlewares' | 'fetch' | 'transformStream' | 'manual'>;
interface XFetchMiddlewares {onRequest?: (...ags: Parameters<typeof fetch>) => Promise<Parameters<typeof fetch>>;onResponse?: (response: Response) => Promise<Response>;}
Status- |
Update Times0 |
Status- |
Update Times0 |
Status- |
Update Times0 |
Status- |