Skip to main content

Request

Class

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

  • Snapchat: not supported
  • SPECS: fully supported
  • Camera Kit Web: not supported
  • Camera Kit Mobile: not supported
  • SnapchatNot supported — Available on SPECS only
  • SPECSFully supported
  • Camera Kit WebNot supported — Available on SPECS only
  • Camera Kit MobileNot supported — Available on SPECS only

Platform details

  • Snapchat — Not supported — Available on SPECS only.

  • SPECS — Fully supported.

  • Camera Kit Web — Not supported — Available on SPECS only.

  • Camera Kit Mobile — Not supported — Available on SPECS only.

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

Index

Example

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

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

Extends

Constructors

Constructor

new Request(input, options?): Request

Parameters

ParameterType
inputstring
options?any

Returns

Request

Overrides

ScriptObject.constructor

Properties

bodyUsed

readonly bodyUsed: boolean

SPECS

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


headers

readonly headers: Headers

SPECS

The Headers of the Request.


method

readonly method: string

SPECS

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


redirect

readonly redirect: string

SPECS

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


url

readonly url: string

SPECS

The URL of the request.

Methods

bytes()

bytes(): Promise<Uint8Array<ArrayBufferLike>>

SPECS

Retreive the body as Uint8Array.

Returns

Promise<Uint8Array<ArrayBufferLike>>


getTypeName()

static getTypeName(): TypeName<Request>

SPECS

Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().

Returns

TypeName<Request>

Overrides

ScriptObject.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

ScriptObject.getTypeName


isOfType()

isOfType(type): boolean

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

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

ScriptObject.isOfType


isSame()

isSame(other): boolean

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

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

ScriptObject.isSame


json()

json(): Promise<any>

SPECS

Retrieve the body as a json object.

Returns

Promise<any>


text()

text(): Promise<string>

SPECS

Retrieve the body as a string.

Returns

Promise<string>