Request class
Used to make AJAX requests and also cache the response in IndexedDB.
It can also return the cached response if the request fails or times out (see StorageMode).
Sets the cache key for the request
cacheKey: The cache key
Parameters
cacheKey: string
Returns this
withCancellationToken
withCancellationToken(cancellationToken): this
Adds a cancellation token to the request (used to cancel the request)
cancellationToken: The cancellation token
Note: The request will finish executing, but the success/error callbacks will not be called if the request is cancelled.
Adds credentials to the request
credentials: The credentials
Parameters
credentials: RequestCredentials
Returns this
withHeaders
withHeaders(headers): this
Adds header values to the request
headers: The header values
Parameters
headers: Record<string, string>
Returns this
withParser
withParser(parser): this
Sets the parser for the request
parser: The parser
Parameters
parser: ((response: Response) => Promise<any>)
(response): Promise<any>
Parameters
response: Response
Returns Promise<any>
Returns this
withRetryAttempts
withRetryAttempts(retryAttempts): this
Sets the number of retry attempts for the request
retryAttempts: The number of retry attempts (default: 3)
Note: The retry attempts are only used for network requests
Parameters
retryAttempts: number
Returns this
withRetryDelay
withRetryDelay(retryDelay): this
Sets the retry delay for the request in milliseconds
retryDelay: The retry delay in milliseconds (default: 1000)
Note: The retry delay is only used for network requests
Parameters
retryDelay: number
Returns this
withSerializer
withSerializer(serializer): this
Sets the serializer for the request
serializer: The serializer
Parameters
serializer: ((data: any) => string)
(data): string
Parameters
data: any
Returns string
Returns this
withStorageMode
withStorageMode(storageMode): this
Sets the storage mode for the request
storageMode: The storage mode
Request class Used to make AJAX requests and also cache the response in IndexedDB. It can also return the cached response if the request fails or times out (see StorageMode).