Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Network

Hierarchy

  • Network

Index

Constructors

constructor

Methods

Static fetch

  • fetch(input: RequestInfo, init?: RequestInit): Promise<Response>
  • Makes a network request

    Use instead of window.fetch because it rejects failed transactions.

    throws

    {ResourceNotFoundException} if not ok

    Parameters

    • input: RequestInfo
    • Optional init: RequestInit

    Returns Promise<Response>

    The result of window.fetch, if it is ok

Static fetchXHR

  • fetchXHR(url: string, __namedParameters?: Partial<XHRNetworkOptions>): Promise<XMLHttpRequest>
  • Promise wrapper for XMLHttpRequest

    Use instead of window.fetch because it rejects failed transactions and provides a legacy XHR interface. If the legacy interface is not a concern, use Network.fetch.

    Doesn't implement timeout logic
    throws

    {ResourceNotFoundException} if the request fails, as defined by the negation of {@param resolveCondition}

    deprecated

    Parameters

    Returns Promise<XMLHttpRequest>

    The XHR as a Promise, with a ResourceNotFoundException in case of rejection

Static loadJSON

  • loadJSON(input: RequestInfo, init?: RequestInit): Promise<any>
  • Makes a network request to a resource and returns its data parsed as JSON

    Use instead of window.fetch because it rejects failed transactions.

    throws

    {ResourceNotFoundException} if not ok

    Parameters

    • input: RequestInfo
    • Optional init: RequestInit

    Returns Promise<any>

    The result of the request to the resource, parsed as JSON, if it is ok

Static loadJSONXHR

  • loadJSONXHR(filePath: string): Promise<any>
  • Fetch a network resource as JSON and return the parsed object

    Use instead of window.fetch because it rejects failed transactions and provides a legacy XHR interface. If the legacy interface is not a concern, use Network.loadJSON.

    Doesn't implement timeout logic
    throws

    {ResourceNotFoundException} if the request fails, defined by the status not being in [200, 300)

    deprecated

    Parameters

    • filePath: string

      The network URL of file to be fetched

    Returns Promise<any>

    The resource as parsed JSON object