Request
import { Request } from "@hyper-fetch/core"
Description
Fetch request it is designed to prepare the necessary setup to execute the request to the server. We can set up basic options for example endpoint, method, headers and advanced settings like cache, invalidation patterns, concurrency, retries and much, much more.
We should not use this class directly in the standard development flow. We can initialize it using the
createRequest
method on the Client class.
Defined in request/request.ts:40
Parameters
Name | Details |
---|---|
client
|
|
requestOptions
|
|
requestJSON
|
|
Properties
client
client
Description
Defined in request/request.ts:92
Type
Client<GlobalError, Adapter, DefaultEndpointMapper>
mock
mock
Description
Defined in request/request.ts:76
Type
Generator<GeneratorReturnMockTypes<Response, Request<Response, Payload, QueryParams, GlobalError, LocalError, Endpoint, Adapter, HasData, HasParams, HasQuery>>, GeneratorReturnMockTypes<Response, Request<Response, Payload, QueryParams, GlobalError, LocalError, Endpoint, Adapter, HasData, HasParams, HasQuery>>, GeneratorReturnMockTypes<Response, Request<Response, Payload, QueryParams, GlobalError, LocalError, Endpoint, Adapter, HasData, HasParams, HasQuery>>>
mockData
mockData
Description
Defined in request/request.ts:81
Type
RequestDataMockTypes<Response, Request<Response, Payload, QueryParams, GlobalError, LocalError, Endpoint, Adapter, HasData, HasParams, HasQuery>>
requestJSON
requestJSON
Description
Defined in request/request.ts:98
Type
RequestCurrentType<Payload, QueryParams, Endpoint, ExtractAdapterOptionsType<Adapter>, ExtractAdapterMethodType<Adapter>>
requestOptions
requestOptions
Description
Defined in request/request.ts:93
Type
RequestOptionsType<Endpoint, ExtractAdapterOptionsType<Adapter>, ExtractAdapterMethodType<Adapter>>
Methods
exec()
exec()
Description
Method to use the request WITHOUT adding it to cache and queues. This mean it will make simple request without queue side effects.
Defined in request/request.ts:471
Return
requestMapper()
requestMapper()
Description
Defined in request/request.ts:83
Return
(request: Request, requestId: string) => NewRequest | Promise<NewRequest>
responseMapper()
responseMapper()
Description
Defined in request/request.ts:84
Return
(response: ResponseReturnType<ExtractResponseType<Request>, ExtractErrorType<Request>, ExtractAdapterType<Request>>) => ResponseReturnType<NewResponse, NewError, ExtractAdapterType<Request>> | Promise<ResponseReturnType<NewResponse, NewError, ExtractAdapterType<Request>>>
send()
send()
Description
Method used to perform requests with usage of cache and queues
Defined in request/request.ts:502
Return
abort()
abort()
Preview
abort()
Description
Defined in request/request.ts:455
Return
Request<Response, Payload, QueryParams, GlobalError, LocalError, Endpoint, Adapter, HasData, HasParams, HasQuery>
clone()
clone()
Preview
clone<D, P, Q>(options)
Description
Defined in request/request.ts:409
Parameters
Name | Details |
---|---|
options
|
|
Return
Request<Response, Payload, QueryParams, GlobalError, LocalError, Endpoint, Adapter, D, P, Q>
setAbortKey()
setAbortKey()
Preview
setAbortKey(abortKey)
Description
Defined in request/request.ts:236
Parameters
Name | Details |
---|---|
abortKey
|
|
Return
Request<Response, Payload, QueryParams, GlobalError, LocalError, Endpoint, Adapter, HasData, HasParams, HasQuery>
setAuth()
setAuth()
Preview
setAuth(auth)
Description
Defined in request/request.ts:164
Parameters
Name | Details |
---|---|
auth
|
|
Return
Request<Response, Payload, QueryParams, GlobalError, LocalError, Endpoint, Adapter, HasData, HasParams, HasQuery>
setCache()
setCache()
Preview
setCache(cache)
Description
Defined in request/request.ts:216
Parameters
Name | Details |
---|---|
cache
|
|
Return
Request<Response, Payload, QueryParams, GlobalError, LocalError, Endpoint, Adapter, HasData, HasParams, HasQuery>
setCacheKey()
setCacheKey()
Preview
setCacheKey(cacheKey)
Description
Defined in request/request.ts:241
Parameters
Name | Details |
---|---|
cacheKey
|
|
Return
Request<Response, Payload, QueryParams, GlobalError, LocalError, Endpoint, Adapter, HasData, HasParams, HasQuery>
setCacheTime()
setCacheTime()
Preview
setCacheTime(cacheTime)
Description
Defined in request/request.ts:222
Parameters
Name | Details |
---|---|
cacheTime
|
|
Return
Request<Response, Payload, QueryParams, GlobalError, LocalError, Endpoint, Adapter, HasData, HasParams, HasQuery>
setCancelable()
setCancelable()
Preview
setCancelable(cancelable)
Description
Defined in request/request.ts:186
Parameters
Name | Details |
---|---|
cancelable
|
|
Return
Request<Response, Payload, QueryParams, GlobalError, LocalError, Endpoint, Adapter, HasData, HasParams, HasQuery>
setData()
setData()
Preview
setData<D>(data)
Description
Defined in request/request.ts:172
Parameters
Name | Details |
---|---|
data
|
|
Return
Request<Response, Payload, QueryParams, GlobalError, LocalError, Endpoint, Adapter, D extends null ? false : true, HasParams, HasQuery>
setDataMapper()
setDataMapper()
Preview
setDataMapper<DataMapper>(dataMapper)
Description
Map data before it gets send to the server
Defined in request/request.ts:314
Parameters
Name | Details |
---|---|
dataMapper
|
|
Return
Request<Response, Payload, QueryParams, GlobalError, LocalError, Endpoint, Adapter, HasData, HasParams, HasQuery>
setDeduplicate()
setDeduplicate()
Preview
setDeduplicate(deduplicate)
Description
Defined in request/request.ts:256
Parameters
Name | Details |
---|---|
deduplicate
|
|
Return
Request<Response, Payload, QueryParams, GlobalError, LocalError, Endpoint, Adapter, HasData, HasParams, HasQuery>
setDeduplicateTime()
setDeduplicateTime()
Preview
setDeduplicateTime(deduplicateTime)
Description
Defined in request/request.ts:260
Parameters
Name | Details |
---|---|
deduplicateTime
|
|
Return
Request<Response, Payload, QueryParams, GlobalError, LocalError, Endpoint, Adapter, HasData, HasParams, HasQuery>
setEffectKey()
setEffectKey()
Preview
setEffectKey(effectKey)
Description
Defined in request/request.ts:251
Parameters
Name | Details |
---|---|
effectKey
|
|
Return
Request<Response, Payload, QueryParams, GlobalError, LocalError, Endpoint, Adapter, HasData, HasParams, HasQuery>
setEnableMocking()
setEnableMocking()
Preview
setEnableMocking(isMockEnabled)
Description
Defined in request/request.ts:300
Parameters
Name | Details |
---|---|
isMockEnabled
|
|
Return
this
setGarbageCollection()
setGarbageCollection()
Preview
setGarbageCollection(garbageCollection)
Description
Defined in request/request.ts:206
Parameters
Name | Details |
---|---|
garbageCollection
|
|
Return
Request<Response, Payload, QueryParams, GlobalError, LocalError, Endpoint, Adapter, HasData, HasParams, HasQuery>
setHeaders()
setHeaders()
Preview
setHeaders(headers)
Description
Defined in request/request.ts:160
Parameters
Name | Details |
---|---|
headers
|
|
Return
Request<Response, Payload, QueryParams, GlobalError, LocalError, Endpoint, Adapter, HasData, HasParams, HasQuery>
setMock()
setMock()
Preview
setMock(mockData)
Description
Defined in request/request.ts:272
Parameters
Name | Details |
---|---|
mockData
|
|
Return
this
setOffline()
setOffline()
Preview
setOffline(offline)
Description
Defined in request/request.ts:268
Parameters
Name | Details |
---|---|
offline
|
|
Return
Request<Response, Payload, QueryParams, GlobalError, LocalError, Endpoint, Adapter, HasData, HasParams, HasQuery>
setOptions()
setOptions()
Preview
setOptions(options)
Description
Defined in request/request.ts:182
Parameters
Name | Details |
---|---|
options
|
|
Return
Request<Response, Payload, QueryParams, GlobalError, LocalError, Endpoint, Adapter, HasData, HasParams, true>
setParams()
setParams()
Preview
setParams<P>(params)
Description
Defined in request/request.ts:168
Parameters
Name | Details |
---|---|
params
|
|
Return
Request<Response, Payload, QueryParams, GlobalError, LocalError, Endpoint, Adapter, HasData, P extends null ? false : true, HasQuery>
setQueryParams()
setQueryParams()
Preview
setQueryParams(queryParams)
Description
Defined in request/request.ts:178
Parameters
Name | Details |
---|---|
queryParams
|
|
Return
Request<Response, Payload, QueryParams, GlobalError, LocalError, Endpoint, Adapter, HasData, HasParams, true>
setQueueKey()
setQueueKey()
Preview
setQueueKey(queueKey)
Description
Defined in request/request.ts:246
Parameters
Name | Details |
---|---|
queueKey
|
|
Return
Request<Response, Payload, QueryParams, GlobalError, LocalError, Endpoint, Adapter, HasData, HasParams, HasQuery>
setQueued()
setQueued()
Preview
setQueued(queued)
Description
Defined in request/request.ts:232
Parameters
Name | Details |
---|---|
queued
|
|
Return
Request<Response, Payload, QueryParams, GlobalError, LocalError, Endpoint, Adapter, HasData, HasParams, HasQuery>
setRequestMapper()
setRequestMapper()
Preview
setRequestMapper<NewRequest>(requestMapper)
Description
Map request before it gets send to the server
Defined in request/request.ts:327
Parameters
Name | Details |
---|---|
requestMapper
| mapper of the request
|
Return
Request<Response, Payload, QueryParams, GlobalError, LocalError, Endpoint, Adapter, HasData, HasParams, HasQuery>
setResponseMapper()
setResponseMapper()
Preview
setResponseMapper<NewResponse, NewError>(responseMapper)
Description
Map the response to the new interface
Defined in request/request.ts:340
Parameters
Name | Details |
---|---|
responseMapper
| our mapping callback
|
Return
Request<NewResponse, Payload, QueryParams, GlobalError, LocalError, Endpoint, Adapter, HasData, HasParams, HasQuery>
setRetry()
setRetry()
Preview
setRetry(retry)
Description
Defined in request/request.ts:190
Parameters
Name | Details |
---|---|
retry
|
|
Return
Request<Response, Payload, QueryParams, GlobalError, LocalError, Endpoint, Adapter, HasData, HasParams, HasQuery>
setRetryTime()
setRetryTime()
Preview
setRetryTime(retryTime)
Description
Defined in request/request.ts:196
Parameters
Name | Details |
---|---|
retryTime
|
|
Return
Request<Response, Payload, QueryParams, GlobalError, LocalError, Endpoint, Adapter, HasData, HasParams, HasQuery>
setUsed()
setUsed()
Preview
setUsed(used)
Description
Defined in request/request.ts:264
Parameters
Name | Details |
---|---|
used
|
|
Return
Request<Response, Payload, QueryParams, GlobalError, LocalError, Endpoint, Adapter, HasData, HasParams, HasQuery>
toJSON()
toJSON()
Preview
toJSON()
Description
Defined in request/request.ts:374
Return
{
abortKey: string;
auth: boolean;
cache: boolean;
cacheKey: string;
cacheTime: number;
cancelable: boolean;
data: Payload | null | undefined;
deduplicate: boolean;
deduplicateTime: number;
disableRequestInterceptors: boolean | undefined;
disableResponseInterceptors: boolean | undefined;
effectKey: string;
endpoint: string;
garbageCollection: number;
headers: HeadersInit;
method: T extends AdapterType<any, infer M, any, any, any> ? M : never;
offline: boolean;
options: AdapterOptions | T extends AdapterType<infer O, any, any, any, any> ? O : never;
params: Params | null | undefined;
queryParams: QueryParams | null | undefined;
queueKey: string;
queued: boolean;
requestOptions: {
abortKey: string;
auth: boolean;
cache: boolean;
cacheKey: string;
cacheTime: number;
cancelable: boolean;
deduplicate: boolean;
deduplicateTime: number;
disableRequestInterceptors: boolean;
disableResponseInterceptors: boolean;
effectKey: string;
endpoint: GenericEndpoint;
garbageCollection: number;
headers: HeadersInit;
method: RequestMethods;
offline: boolean;
options: AdapterOptions;
queueKey: string;
queued: boolean;
retry: number;
retryTime: number;
};
retry: number;
retryTime: number;
updatedAbortKey: boolean;
updatedCacheKey: boolean;
updatedEffectKey: boolean;
updatedQueueKey: boolean;
used: boolean;
}