Lens Scripting API
    Preparing search index...

    Class ResponseWearable Only

    Represents an HTTP response used by the Fetch API in RemoteServiceModule.

    let response = await this.remoteServiceModule.fetch(request);
    if (response.ok) {
    let contentType = response.headers.get("Content-Type");
    if (contentType === "application/json") {
    let responseJson = await response.json();
    let username = responseJson.json["user"];

    ...
    }
    }

    Hierarchy (View Summary)

    Index

    Constructors

    • Wearable Only

      The Response() constructor creates a new Response object.

      Parameters

      • Optionalbody: string | Uint8Array | Blob

        An object defining a body for the response. This can be null (which is the default value), or one of: Blob, TypedArray, or string.

      • Optionaloptions: any

        An options object containing any custom settings that you want to apply to the response, or an empty object (which is the default value). The possible options are:

        • status - The status code for the response. The default value is 200.
        • statusText - The status message associated with the status code, such as "OK". The default value is "".
        • headers - Any headers you want to add to your response, contained within a Headers object or object literal of String key/value pairs (see HTTP headers for a reference). By default this is empty.

      Returns Response

    Properties

    bodyUsed: boolean

    True if one of the body retrieval methods has been called for this Response.

    headers: Headers

    The Headers of the Response.

    ok: boolean

    True if the response returned HTTP Status Code 200 (OK).

    status: number

    The response's HTTP status code. HTTP status code values: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status.

    statusText: string

    The HTTP status code converted to string.

    url: string

    The URL of the Response. This is the final URL obtained after any redirects.

    Methods

    • Wearable Only

      Retrieve the body as a Blob.

      Returns Promise<Blob>

    • Wearable Only

      Retrieve the body as Uint8Array.

      Returns Promise<Uint8Array>

    • Returns true if the object matches or derives from the passed in type.

      Parameters

      • type: string

      Returns boolean

    • Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

      Parameters

      Returns boolean

    • Wearable Only

      Retrieve the body as a json object.

      Returns Promise<any>

    • Wearable Only

      Retrieve the body as a string.

      Returns Promise<string>