fexios
Version:
Fetch based HTTP client with similar API to axios for browser and Node.js
55 lines (54 loc) • 2.78 kB
TypeScript
import { default as CallableInstance } from 'callable-instance';
import { FexiosConfigs, FexiosContext, FexiosRequestOptions, FexiosFinalContext, FexiosHookStore, FexiosLifecycleEvents, FexiosHook, FexiosInterceptors, FexiosRequestShortcut } from './types';
import { checkIsPlainObject, dropUndefinedAndNull } from './utils';
/**
* Fexios
* @desc Fetch based HTTP client with similar API to axios for browser and Node.js
*/
export declare class Fexios extends CallableInstance<[
string | URL | Partial<FexiosRequestOptions>,
Partial<FexiosRequestOptions>?
], Promise<FexiosFinalContext<any>>> {
baseConfigs: Partial<FexiosConfigs>;
protected hooks: FexiosHookStore[];
readonly DEFAULT_CONFIGS: FexiosConfigs;
private readonly ALL_METHODS;
private readonly METHODS_WITHOUT_BODY;
constructor(baseConfigs?: Partial<FexiosConfigs>);
request<T = any>(url: string | URL, options?: Partial<FexiosRequestOptions>): Promise<FexiosFinalContext<T>>;
request<T = any>(options: Partial<FexiosRequestOptions> & {
url: string | URL;
}): Promise<FexiosFinalContext<T>>;
mergeQuery(base: Record<string, any> | string | URLSearchParams | undefined, ...income: (Record<string, any> | string | URLSearchParams | undefined)[]): Record<string, any>;
mergeHeaders(base: Record<string, any> | Headers | undefined, ...income: (Record<string, any> | Headers | undefined)[]): Record<string, string>;
emit<C = FexiosContext>(event: FexiosLifecycleEvents, ctx: C): Promise<C>;
on<C = FexiosContext>(event: FexiosLifecycleEvents, action: FexiosHook<C>, prepend?: boolean): this;
off(event: FexiosLifecycleEvents | '*' | null, action: FexiosHook<any>): this;
private createInterceptor;
readonly interceptors: FexiosInterceptors;
private createMethodShortcut;
extends(configs: Partial<FexiosConfigs>): Fexios;
readonly create: typeof Fexios.create;
static create(configs?: Partial<FexiosConfigs>): Fexios;
/**
* Remove all undefined and null properties from an object
* Also handles empty strings based on options
* @deprecated Use dropUndefinedAndNull from utils instead
*/
readonly dropUndefinedAndNull: typeof dropUndefinedAndNull;
/**
* Check if given payload is a plain object
* @deprecated Use checkIsPlainObject from utils instead
*/
readonly checkIsPlainObject: typeof checkIsPlainObject;
}
export interface Fexios {
get: FexiosRequestShortcut<'get'>;
post: FexiosRequestShortcut<'post'>;
put: FexiosRequestShortcut<'put'>;
patch: FexiosRequestShortcut<'patch'>;
delete: FexiosRequestShortcut<'delete'>;
head: FexiosRequestShortcut<'head'>;
options: FexiosRequestShortcut<'options'>;
trace: FexiosRequestShortcut<'trace'>;
}