Lens Scripting API

    Class RequestWearable Only

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

    let request = new Request("https://example.com", {
    method: "POST",
    body: '{"foo": "bar"}',
    });

    let url = request.url;
    let method = request.method;
    let body = request.json();

    Hierarchy (View Summary, Expand)

    Index

    Constructors

    • Construct a new Request. Takes a URL and an optional JSON object with options. Available options are body, method, headers, redirect, and keepalive.

      let request = new Request("https://<Your URL>.com", {
      method: "POST",
      body: JSON.stringify({ user: { name: "user", career: "developer" }}),
      headers: {
      "Content-Type": "application/json",
      },
      });

      Parameters

      • input: string
      • Optionaloptions: any

      Returns Request

    Properties

    bodyUsed: boolean

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

    headers: Headers

    The Headers of the Request.

    method: string

    The HTTP request method. Must be one of these strings: GET, POST, PUT, or DELETE. Default is GET.

    redirect: string

    Indicates how redirects are handled. Can be one the following strings: follow, error, or manual. Default value is follow.

    url: string

    The URL of the request.

    Methods

    • Retreive the body as Uint8Array.

      Returns any

    • 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

    • Retrieve the body as a json object.

      Returns any

    • Retrieve the body as a string.

      Returns any

    MMNEPVFCICPMFPCPTTAAATR