Skip to main content
Version: 5.x.x

mocker


import { mocker } from "@hyper-fetch/core"

Description

Defined in mocker/mocker.ts:4

Preview

mocker<T>(request, __namedParameters)

Parameters

NameDetails

request

Required

RequestInstance

__namedParameters

Required

Pick<{ config: ExtractAdapterOptionsType<T>; createAbortListener: (status: ExtractAdapterStatusType<T>, abortExtra: ExtractAdapterExtraType<T>, callback: () => void, resolve: (value: ResponseReturnErrorType<ExtractErrorType<T>, T>) => void) => () => void; data: any; fullUrl: string; getAbortController: () => AbortController; getRequestStartTimestamp: () => number; getResponseStartTimestamp: () => number; headers: HeadersInit; makeRequest: (apiCall: (resolve: (value: ResponseReturnType<any, any, T> | PromiseLike<ResponseReturnType<any, any, T>>) => void) => void) => Promise<ResponseReturnType<any, any, T>>; onAbortError: (status: ExtractAdapterStatusType<T>, extra: ExtractAdapterExtraType<T>, resolve: (value: ResponseReturnErrorType<ExtractErrorType<T>, T>) => void) => Promise<ResponseReturnErrorType<any, T>>; onBeforeRequest: () => void; onError: (error: any, status: ExtractAdapterStatusType<T>, extra: ExtractAdapterExtraType<T>, resolve: (value: ResponseReturnErrorType<any, T>) => void) => Promise<ResponseReturnErrorType<any, T>>; onRequestEnd: () => number; onRequestProgress: (progress: ProgressDataType) => number; onRequestStart: (progress?: ProgressDataType) => number; onResponseEnd: () => number; onResponseProgress: (progress: ProgressDataType) => number; onResponseStart: (progress?: ProgressDataType) => number; onSuccess: (responseData: any, status: ExtractAdapterStatusType<T>, extra: ExtractAdapterExtraType<T>, resolve: (value: ResponseReturnErrorType<any, T>) => void) => Promise<ResponseReturnSuccessType<ExtractResponseType<T>, T>>; onTimeoutError: (status: ExtractAdapterStatusType<T>, extra: ExtractAdapterExtraType<T>, resolve: (value: ResponseReturnErrorType<ExtractErrorType<T>, T>) => void) => Promise<ResponseReturnErrorType<any, T>>; onUnexpectedError: (status: ExtractAdapterStatusType<T>, extra: ExtractAdapterExtraType<T>, resolve: (value: ResponseReturnErrorType<ExtractErrorType<T>, T>) => void) => Promise<ResponseReturnErrorType<any, T>>; payload: any }, onRequestStart | onResponseStart | onError | onSuccess | onResponseEnd | onTimeoutError | onRequestEnd | createAbortListener | onResponseProgress | onRequestProgress | onBeforeRequest>

Returns

Promise<ResponseReturnType<any, any, any>>