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).

Constructors

Methods

  • Aborts the request, if it is still running, and calls the error callback. Note: This is only supported for network requests

    Returns this

  • Sets the error callback for the request callback: The error callback

    Parameters

    • callback: ((reason: any) => void)
        • (reason): void
        • Parameters

          • reason: any

          Returns void

    Returns this

  • Sets the retry callback for the request callback: The retry callback

    Parameters

    • callback: ((attempt: number) => void)
        • (attempt): void
        • Parameters

          • attempt: number

          Returns void

    Returns this

  • Sets the success callback for the request callback: The success callback

    Parameters

    • callback: ((response: any) => void)
        • (response): void
        • Parameters

          • response: any

          Returns void

    Returns this

  • Actually sends the request, parses it, and calls either the success or error functions if they exist. Returns the parsed response.

    Returns Promise<any>

  • Adds an authentication provider to the request (used to authenticate the request) authenticationProvider: The authentication provider

    Parameters

    Returns this

  • Sets the cache to use for the request cacheName: The cache name cache: The cache to use (default: IndexedDB)

    Parameters

    Returns this

  • Sets the cache key for the request cacheKey: The cache key

    Parameters

    • cacheKey: string

    Returns 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.

    Parameters

    Returns this

  • Adds credentials to the request credentials: The credentials

    Parameters

    • credentials: RequestCredentials

    Returns this

  • Adds header values to the request headers: The header values

    Parameters

    • headers: Record<string, string>

    Returns 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

  • 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

  • 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

  • Sets the serializer for the request serializer: The serializer

    Parameters

    • serializer: ((data: any) => string)
        • (data): string
        • Parameters

          • data: any

          Returns string

    Returns this

  • Sets the storage mode for the request storageMode: The storage mode

    Parameters

    Returns this

  • Sets the timeout for the request timeout: The timeout in milliseconds (default: 60000) Note: The timeout is only used for network requests

    Parameters

    • Optionaltimeout: number

    Returns this

  • Creates a DELETE request Note: DELETE requests are not cached by default url: The request url data: The request data

    Parameters

    • url: string
    • Optionaldata: any

    Returns Request

  • Creates a GET request Note: GET requests are cached by default url: The request url data: The request data

    Parameters

    • url: string
    • Optionaldata: any

    Returns Request

  • Creates a request of the specified type (e.g. GET, POST, PUT, DELETE, etc.) method: The request method url: The request url data: The request data

    Parameters

    • method: string
    • url: string
    • Optionaldata: any

    Returns Request

  • Creates a POST request Note: POST requests are not cached by default url: The request url data: The request data

    Parameters

    • url: string
    • Optionaldata: any

    Returns Request

  • Creates a PUT request Note: PUT requests are not cached by default url: The request url data: The request data

    Parameters

    • url: string
    • Optionaldata: any

    Returns Request