Response

open class Response(response: Response, val request: Request, val propagate: Boolean = true)

Represents the common fields and attributes of an HTTP response. It contains also the original Request which was made to get this Response.

More info at MDN

Constructors

Link copied to clipboard
constructor(response: Response, request: Request, propagate: Boolean = true)

Properties

Link copied to clipboard

returns the Headers from the given Response

Link copied to clipboard
val ok: Boolean

A boolean indicating whether the response was successful (status in the range 200 – 299) or not.

Link copied to clipboard
val propagate: Boolean = true
Link copied to clipboard

Indicates whether or not the response is the result of a redirect (that is, its URL list has more than one entry).

Link copied to clipboard
Link copied to clipboard
val status: Int

The status code of the response. (This will be 200 for a success).

Link copied to clipboard

The status message corresponding to the status code. (e.g., OK for 200).

Link copied to clipboard

The type of the response (e.g., basic, cors).

Link copied to clipboard
val url: String

The URL of the response.

Functions

Link copied to clipboard
suspend fun arrayBuffer(): ArrayBuffer

extracts the body as arrayBuffer from the given Response

Link copied to clipboard
suspend fun blob(): Blob

extracts the body as blob from the given Response

Link copied to clipboard
suspend fun body(): String

extracts the body as string from the given Response

Link copied to clipboard
fun copy(response: Response = this.response, request: Request = this.request, propagate: Boolean = this.propagate): Response

creates a copy of the Response.

Link copied to clipboard
suspend fun formData(): FormData

extracts the body as formData from the given Response

Link copied to clipboard
suspend fun json(): Any?

extracts the body as json from the given Response