RequestOptionsType
Configuration options for request creation
import { RequestOptionsType } from "@hyper-fetch/core"
Preview
type RequestOptionsType<GenericEndpoint,AdapterOptions,RequestMethods> = {
abortKey?: string;
auth?: boolean;
cache?: boolean;
cacheKey?: string;
cacheTime?: number;
cancelable?: boolean;
deduplicate?: boolean;
deduplicateTime?: number;
disableRequestInterceptors?: boolean;
disableResponseInterceptors?: boolean;
endpoint: GenericEndpoint;
headers?: HeadersInit;
method?: RequestMethods;
offline?: boolean;
options?: AdapterOptions;
queryKey?: string;
queued?: boolean;
retry?: number;
retryTime?: number;
staleTime?: number;
}
Structure
| Name | Type | Description |
|---|---|---|
| abortKey | | Key which will be used to cancel requests. Autogenerated by default. |
| auth | | Should the onAuth method get called on this request |
| cache | | Should we save the response to cache |
| cacheKey | | Key which will be used to cache requests. Autogenerated by default. |
| cacheTime | | Should we trigger garbage collection or leave data in memory |
| cancelable | | Should enable cancelable mode in the Dispatcher |
| deduplicate | | Should we deduplicate two requests made at the same time into one |
| deduplicateTime | | Time of pooling for the deduplication to be active (default 10ms) |
| disableRequestInterceptors | | Disable pre-request interceptors |
| disableResponseInterceptors | | Disable post-request interceptors |
| endpoint | | Determine the endpoint for request request |
| headers | | Custom headers for request |
| method | | Request method picked from method names handled by adapter With default adapter it is GET | POST | PATCH | PUT | DELETE |
| offline | | Do we want to store request made in offline mode for latter use when we go back online |
| options | | Additional options for your adapter, by default XHR options |
| queryKey | | Key which will be used to queue requests. Autogenerated by default. |
| queued | | Should the requests from this request be send one-by-one |
| retry | | Retry count when request is failed |
| retryTime | | Retry time delay between retries |
| staleTime | | Time for which the cache is considered up-to-date |