Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace fetch

Namespace that comprises various utils (also cleans up documentation).

Index

Functions

fetchAsync

  • fetchAsync<T>(url: string, type: XMLHttpRequestResponseType): Promise<T>
  • Creates a promise for an asynchronous xml/http request on a given URL. If an URL is fetched successfully, the promise is resolved with the fetched data.

    Type parameters

    • T

    Parameters

    • url: string

      Uniform resource locator string referencing a file.

    • type: XMLHttpRequestResponseType

      Request response type.

    Returns Promise<T>

    • A promise that resolves on a parsed object if successful.

fetchJsonAsync

  • fetchJsonAsync<T>(url: string, transform: FetchTransform<T>, schema?: any): Promise<T>
  • Creates a promise for an asynchronous xml/http request on a given URL. If an URL is fetched successfully, the promise is resolved with a parsed JSON object. An error code and message can be caught otherwise.

    Type parameters

    • T

    Parameters

    • url: string

      Uniform resource locator string referencing a JSON file.

    • transform: FetchTransform<T>

      Callback to a function that transforms the fetched data into an instance of targeted type.

    • Optional schema: any

      Optional schema, that if specified, is used to validate the fetched json data.

    Returns Promise<T>

    • A promise that resolves on a parsed JSON object if successful.