Response
ClassRepresents 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
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
| Parameter | Type |
|---|---|
body | string | Uint8Array<ArrayBufferLike> | Blob |
options? | any |
Returns
Response
Overrides
ScriptObject.constructor
Properties
bodyUsed
readonlybodyUsed:boolean
SPECS
True if one of the body retrieval methods has been called for this Response.
headers
readonlyheaders:Headers
SPECS
The Headers of the Response.
ok
readonlyok:boolean
SPECS
True if the response returned HTTP Status Code 200 (OK).
status
readonlystatus:number
SPECS
The response's HTTP status code. HTTP status code values: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status.
statusText
readonlystatusText:string
SPECS
The HTTP status code converted to string.
url
readonlyurl: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()
staticgetTypeName():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
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object matches or derives from the passed in type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
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
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean
Inherited from
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>