Fetcher: {
    addEventListener: (<T>(type: T, listener: EventListener<FetcherEventMap[T], T, FetcherEventDispatcher>) => void);
    arrayBuffer: ((input: URL | RequestInfo, options?: RequestInit) => Promise<ArrayBuffer>);
    blob: ((input: URL | RequestInfo, options?: RequestInit) => Promise<Blob>);
    fetch: ((input: URL | RequestInfo, options?: FetchOptions) => Promise<Response>);
    hasEventListener: (<T>(type: T, listener: EventListener<FetcherEventMap[T], T, FetcherEventDispatcher>) => boolean);
    json: (<T>(input: URL | RequestInfo, options?: RequestInit) => Promise<T>);
    removeEventListener: (<T>(type: T, listener: EventListener<FetcherEventMap[T], T, FetcherEventDispatcher>) => void);
    text: ((input: URL | RequestInfo, options?: RequestInit) => Promise<string>);
    texture: ((input: URL | RequestInfo, options?: RequestInit & {
        createDataTexture?: boolean;
        flipY?: boolean;
    }) => Promise<Texture>);
    xml: ((input: URL | RequestInfo, options?: RequestInit) => 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: T, listener: EventListener<FetcherEventMap[T], T, FetcherEventDispatcher>) => void)
      • <T>(type, listener): void
      • Adds a listener to an event type on fetch operations.

        Type Parameters

        • T extends "error"

        Parameters

        Returns void

  • arrayBuffer: ((input: URL | RequestInfo, options?: RequestInit) => Promise<ArrayBuffer>)
      • (input, options?): Promise<ArrayBuffer>
      • Wrapper over fetch to get some ArrayBuffer

        fires error event On Network/HTTP error.

        Parameters

        • input: URL | RequestInfo

          the URL to fetch, or the resource request.

        • Optionaloptions: RequestInit

          fetch options (passed directly to fetch())

        Returns Promise<ArrayBuffer>

        the promise containing the ArrayBuffer

  • blob: ((input: URL | RequestInfo, options?: RequestInit) => Promise<Blob>)
      • (input, options?): Promise<Blob>
      • Wrapper over fetch, then returns the blob of the response.

        fires error event On Network/HTTP error.

        Parameters

        • input: URL | RequestInfo

          the URL to fetch, or the resource request.

        • Optionaloptions: RequestInit

          fetch options (passed directly to fetch())

        Returns Promise<Blob>

        The response blob.

  • fetch: ((input: URL | RequestInfo, options?: FetchOptions) => Promise<Response>)
      • (input, 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

        • input: URL | RequestInfo

          the fetch input

        • Optionaloptions: FetchOptions

          fetch options (passed directly to fetch())

        Returns Promise<Response>

        The response object.

  • hasEventListener: (<T>(type: T, listener: EventListener<FetcherEventMap[T], T, FetcherEventDispatcher>) => 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>(input: URL | RequestInfo, options?: RequestInit) => Promise<T>)
      • <T>(input, options?): Promise<T>
      • Wrapper over fetch to get some JSON

        fires error event On Network/HTTP error.

        Type Parameters

        • T = unknown

        Parameters

        • input: URL | RequestInfo

          the URL to fetch, or the resource request.

        • Optionaloptions: RequestInit

          fetch options (passed directly to fetch())

        Returns Promise<T>

        the promise containing the JSON

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

        Type Parameters

        • T extends "error"

        Parameters

        Returns void

  • text: ((input: URL | RequestInfo, options?: RequestInit) => Promise<string>)
      • (input, options?): Promise<string>
      • Wrapper over fetch to get some text

        fires error event On Network/HTTP error.

        Parameters

        • input: URL | RequestInfo

          the URL to fetch, or the resource request.

        • Optionaloptions: RequestInit

          fetch options (passed directly to fetch())

        Returns Promise<string>

        the promise containing the text

  • texture: ((input: URL | RequestInfo, options?: RequestInit & {
        createDataTexture?: boolean;
        flipY?: boolean;
    }) => Promise<Texture>)
      • (input, options?): Promise<Texture>
      • Downloads a remote image and converts it into a texture.

        fires error event On Network/HTTP error.

        Parameters

        • input: URL | RequestInfo

          the URL to fetch, or the resource request.

        • Optionaloptions: RequestInit & {
              createDataTexture?: boolean;
              flipY?: boolean;
          }

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

        Returns Promise<Texture>

        the promise containing the texture

  • xml: ((input: URL | RequestInfo, options?: RequestInit) => Promise<Document>)
      • (input, options?): Promise<Document>
      • Wrapper over fetch to get some XML.

        fires error event On Network/HTTP error.

        Parameters

        • input: URL | RequestInfo

          the URL to fetch, or the resource request.

        • Optionaloptions: RequestInit

          fetch options (passed directly to fetch())

        Returns Promise<Document>

        the promise containing the XML