Response

open class Response(body: BodyInit? = definedExternally, init: ResponseInit = definedExternally) : Body(source)

The Response interface of the Fetch API represents the response to a request.

MDN Reference

Constructors

Link copied to clipboard
constructor(body: BodyInit? = definedExternally, init: ResponseInit = definedExternally)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The body read-only property of the Request interface contains a ReadableStream with the body contents that have been added to the request. Note that a request using the GET or HEAD method cannot have a body and null is returned in these cases.

Link copied to clipboard
open val bodyUsed: Boolean

The bodyUsed read-only property of the Request interface is a boolean value that indicates whether the request body has been read yet.

Link copied to clipboard

The headers read-only property of the Response interface contains the Headers object associated with the response.

Link copied to clipboard
val ok: Boolean

The ok read-only property of the Response interface contains a Boolean stating whether the response was successful (status in the range 200-299) or not.

Link copied to clipboard

The redirected read-only property of the Response interface indicates whether or not the response is the result of a request you made which was redirected.

Link copied to clipboard

The status read-only property of the Response interface contains the HTTP status codes of the response.

Link copied to clipboard

The statusText read-only property of the Response interface contains the status message corresponding to the HTTP status code in Response.status.

Link copied to clipboard

The type read-only property of the Response interface contains the type of the response. The type determines whether scripts are able to access the response body and headers.

Link copied to clipboard
val url: String

The url read-only property of the Response interface contains the URL of the response. The value of the url property will be the final URL obtained after any redirects.

Functions

Link copied to clipboard
inline suspend fun Body.arrayBuffer(): ArrayBuffer

The arrayBuffer() method of the Request interface reads the request body and returns it as a promise that resolves with an ArrayBuffer.

Link copied to clipboard

The arrayBuffer() method of the Request interface reads the request body and returns it as a promise that resolves with an ArrayBuffer.

Link copied to clipboard
inline suspend fun Body.blob(): Blob

The blob() method of the Request interface reads the request body and returns it as a promise that resolves with a Blob.

Link copied to clipboard
open fun blobAsync(): Promise<Blob>

The blob() method of the Request interface reads the request body and returns it as a promise that resolves with a Blob.

Link copied to clipboard
suspend fun Body.byteArray(): ByteArray
Link copied to clipboard
inline suspend fun Body.bytes(): Uint8Array<ArrayBuffer>

The bytes() method of the Request interface reads the request body and returns it as a promise that resolves with a Uint8Array.

Link copied to clipboard

The bytes() method of the Request interface reads the request body and returns it as a promise that resolves with a Uint8Array.

Link copied to clipboard

The clone() method of the Response interface creates a clone of a response object, identical in every way, but stored in a different variable.

Link copied to clipboard
inline suspend fun Body.formData(): FormData

The formData() method of the Request interface reads the request body and returns it as a promise that resolves with a FormData object.

Link copied to clipboard

The formData() method of the Request interface reads the request body and returns it as a promise that resolves with a FormData object.

Link copied to clipboard
inline suspend fun Body.json(): ERROR CLASS: Symbol not found for JsAny??

The json() method of the Request interface reads the request body and returns it as a promise that resolves with the result of parsing the body text as JSON.

Link copied to clipboard
open fun jsonAsync(): Promise<*>

The json() method of the Request interface reads the request body and returns it as a promise that resolves with the result of parsing the body text as JSON.

Link copied to clipboard
inline suspend fun Body.text(): String

The text() method of the Request interface reads the request body and returns it as a promise that resolves with a String. The response is always decoded using UTF-8.

Link copied to clipboard
open fun textAsync(): Promise<ERROR CLASS: Symbol not found for JsString>

The text() method of the Request interface reads the request body and returns it as a promise that resolves with a String. The response is always decoded using UTF-8.

Link copied to clipboard
open fun textStream(): ReadableStream<ERROR CLASS: Symbol not found for JsString>