Fetcher: {
    addEventListener: (<T>(type, listener) => void);
    arrayBuffer: ((url, options?) => Promise<ArrayBuffer>);
    blob: ((url, options?) => Promise<Blob>);
    fetch: ((url, options?) => Promise<Response>);
    getInfo: {};
    hasEventListener: (<T>(type, listener) => boolean);
    json: (<T>(url, options?) => Promise<T>);
    removeEventListener: (<T>(type, listener) => void);
    text: ((url, options?) => Promise<string>);
    texture: ((url, options?) => Promise<Texture>);
    xml: ((url, options?) => Promise<Document>);
}

Exposes an API to perform HTTP requests. This should be used instead of the Fetch API in order to benefit from some error-checking, automatic configuration (from the HttpConfiguration module), etc.

Type declaration

  • addEventListener: (<T>(type, listener) => void)
      • <T>(type, listener): void
      • Adds a listener to an event type on fetch operations.

        Type Parameters

        • T extends "error"

        Parameters

        Returns void

  • arrayBuffer: ((url, options?) => Promise<ArrayBuffer>)
      • (url, options?): Promise<ArrayBuffer>
      • Wrapper over fetch to get some ArrayBuffer

        fires error event On Network/HTTP error.

        Parameters

        • url: string

          the URL to fetch

        • Optional options: RequestInit

          fetch options (passed directly to fetch())

        Returns Promise<ArrayBuffer>

        the promise containing the ArrayBuffer

  • blob: ((url, options?) => Promise<Blob>)
      • (url, options?): Promise<Blob>
      • Wrapper over fetch, then returns the blob of the response.

        fires error event On Network/HTTP error.

        Parameters

        • url: string

          the URL to fetch

        • Optional options: RequestInit

          fetch options (passed directly to fetch())

        Returns Promise<Blob>

        The response blob.

  • fetch: ((url, options?) => Promise<Response>)
      • (url, options?): Promise<Response>
      • Wrapper over fetch().

        Use this function instead of calling directly the Fetch API to benefit from automatic configuration from the HttpConfiguration module.

        fires error event On Network/HTTP error.

        Parameters

        • url: string

          the URL to fetch

        • Optional options: FetchOptions

          fetch options (passed directly to fetch())

        Returns Promise<Response>

        The response object.

  • getInfo: {}
    • hasEventListener: (<T>(type, listener) => boolean)
        • <T>(type, listener): boolean
        • Checks if listener is added to an event type.

          Type Parameters

          • T extends "error"

          Parameters

          Returns boolean

          true if the listener is added to this event type.

    • json: (<T>(url, options?) => Promise<T>)
        • <T>(url, options?): Promise<T>
        • Wrapper over fetch to get some JSON

          fires error event On Network/HTTP error.

          Type Parameters

          • T = unknown

          Parameters

          • url: string

            the URL to fetch

          • Optional options: RequestInit

            fetch options (passed directly to fetch())

          Returns Promise<T>

          the promise containing the JSON

    • removeEventListener: (<T>(type, listener) => void)
        • <T>(type, listener): void
        • Removes a listener from an event type on fetch operations.

          Type Parameters

          • T extends "error"

          Parameters

          Returns void

    • text: ((url, options?) => Promise<string>)
        • (url, options?): Promise<string>
        • Wrapper over fetch to get some text

          fires error event On Network/HTTP error.

          Parameters

          • url: string

            the URL to fetch

          • Optional options: RequestInit

            fetch options (passed directly to fetch())

          Returns Promise<string>

          the promise containing the text

    • texture: ((url, options?) => Promise<Texture>)
        • (url, options?): Promise<Texture>
        • Downloads a remote image and converts it into a texture.

          fires error event On Network/HTTP error.

          Parameters

          • url: string

            the URL to fetch

          • Optional options: RequestInit & {
                createDataTexture?: boolean;
                flipY?: boolean;
            }

            Texture creation options and fetch options (passed directly to fetch())

          Returns Promise<Texture>

          the promise containing the texture

    • xml: ((url, options?) => Promise<Document>)
        • (url, options?): Promise<Document>
        • Wrapper over fetch to get some XML.

          fires error event On Network/HTTP error.

          Parameters

          • url: string

            the URL to fetch

          • Optional options: RequestInit

            fetch options (passed directly to fetch())

          Returns Promise<Document>

          the promise containing the XML