Skip to main content

Response

Class

Represents an HTTP response 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 response used by the Fetch API in RemoteServiceModule.

Index

Example

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"];

...
}
}

Extends

Constructors

Constructor

new Response(body, options?): Response

Parameters

ParameterType
bodystring | Uint8Array<ArrayBufferLike> | Blob
options?any

Returns

Response

Overrides

ScriptObject.constructor

Properties

bodyUsed

readonly bodyUsed: boolean

SPECS

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


headers

readonly headers: Headers

SPECS

The Headers of the Response.


ok

readonly ok: boolean

SPECS

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


status

readonly status: number

SPECS

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


statusText

readonly statusText: string

SPECS

The HTTP status code converted to string.


url

readonly url: string

SPECS

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

Methods

blob()

blob(): Promise<Blob>

SPECS

Retrieve the body as a Blob.

Returns

Promise<Blob>


bytes()

bytes(): Promise<Uint8Array<ArrayBufferLike>>

SPECS

Retrieve the body as Uint8Array.

Returns

Promise<Uint8Array<ArrayBufferLike>>


getTypeName()

static getTypeName(): TypeName<Response>

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<Response>

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>