dev-classes
Version:
<h3 align="center">SocketApi</h3>
44 lines (42 loc) • 1.58 kB
TypeScript
import { RequestUploadToken_F, RequestOptions_P } from './types/apiRequest.types';
import { CookieAttributes } from 'node_modules/@types/js-cookie';
import { AxiosRequestConfig, AxiosResponse } from 'axios';
export * from './types/apiRequest.types';
export interface FetchCommonApiRequest {
statusCode: number;
url: string;
}
export interface ResolveRequestInServer_P<ResT> extends FetchCommonApiRequest {
data: ResT;
res: AxiosResponse<ResT>;
}
export interface RejectRequestInServer_P extends FetchCommonApiRequest {
isErr: boolean;
msg: string;
request: RequestOptions_P;
errExt?: {
code?: string;
config?: AxiosRequestConfig;
headers?: object;
message: string;
status: number;
data?: any;
statusText?: string;
stack?: string;
};
}
export declare class apiRequest {
private static keyCookie;
private static cookieOptions;
private static registerRequest;
private static registerFailedRequests;
private static requestUploadToken;
private static errorsHandler;
static setMethodUploadToken: (cb: RequestUploadToken_F) => void;
static requestInServer: <ResT = any, T extends object = ResolveRequestInServer_P<ResT>>(url: string, options?: RequestOptions_P) => Promise<T>;
static getAuthCookies: () => any;
static saveToken: (token: string) => void;
static removeAuthCookie: () => void;
static setCookieOptions: (options: CookieAttributes) => void;
static setErrorsHandler(errorsHandler: typeof apiRequest.errorsHandler): void;
}