Request

open class Request(baseUrl: String, headers: Map<String, String>, body: dynamic, referrer: String?, referrerPolicy: dynamic, mode: RequestMode?, credentials: RequestCredentials?, cache: RequestCache?, redirect: RequestRedirect?, integrity: String?, keepalive: Boolean?, reqWindow: Any?, authentication: Authentication?)

Represents the common fields an attributes of a given set of http requests.

Use it to define common headers, error-handling, base url, etc. for a specific API for example. By calling one of the executing methods like get or post a specific request is built from the template and send to the server.

Constructors

Request
Link copied to clipboard
js
fun Request(baseUrl: String = "", headers: Map<String, String> = emptyMap(), body: dynamic = undefined, referrer: String? = undefined, referrerPolicy: dynamic = undefined, mode: RequestMode? = undefined, credentials: RequestCredentials? = undefined, cache: RequestCache? = undefined, redirect: RequestRedirect? = undefined, integrity: String? = undefined, keepalive: Boolean? = undefined, reqWindow: Any? = undefined, authentication: Authentication? = null)

Functions

accept
Link copied to clipboard
js
fun accept(value: String): Request
adds the given Accept value to the http headers, e.
acceptJson
Link copied to clipboard
js
fun acceptJson(): Request
adds a header to accept JSON as response
append
Link copied to clipboard
js
fun append(subUrl: String): Request
appends the given subUrl to the baseUrl
arrayBuffer
Link copied to clipboard
js
fun arrayBuffer(content: ArrayBuffer): Request
sets the ArrayBuffer content to the request
authentication
Link copied to clipboard
js
fun authentication(auth: Authentication): Request
sets the general Authentication mechanism of the Request
basicAuth
Link copied to clipboard
js
fun basicAuth(username: String, password: String): Request
adds the basic Authorization header for the given username and password
blob
Link copied to clipboard
js
fun blob(content: Blob): Request
sets the Blob content to the request
body
Link copied to clipboard
js
fun body(content: String): Request
sets the body content to the request
cache
Link copied to clipboard
js
fun cache(value: RequestCache): Request
sets the cache property of the Request
cacheControl
Link copied to clipboard
js
fun cacheControl(value: String): Request
adds the given Cache-Control value to the http headers
connect
Link copied to clipboard
js
suspend fun connect(subUrl: String = ""): Response
issues a connect request returning a flow of it's response
contentType
Link copied to clipboard
js
fun contentType(value: String): Request
adds the given Content-Type value to the http headers
credentials
Link copied to clipboard
js
fun credentials(value: RequestCredentials): Request
sets the credentials property of the Request
delete
Link copied to clipboard
js
open suspend fun delete(subUrl: String = ""): Response
issues a delete request returning a flow of it's response
equals
Link copied to clipboard
js
open operator fun equals(other: Any?): Boolean
formData
Link copied to clipboard
js
fun formData(content: FormData): Request
sets the FormData content to the request
get
Link copied to clipboard
js
suspend fun get(subUrl: String = ""): Response
issues a get request returning a flow of it's response
hashCode
Link copied to clipboard
js
open fun hashCode(): Int
head
Link copied to clipboard
js
suspend fun head(subUrl: String = ""): Response
issues a head request returning a flow of it's response
header
Link copied to clipboard
js
fun header(name: String, value: String): Request
adds the given http header to the request
integrity
Link copied to clipboard
js
fun integrity(value: String): Request
sets the integrity property of the Request
keepalive
Link copied to clipboard
js
fun keepalive(value: Boolean): Request
sets the keepalive property of the Request
options
Link copied to clipboard
js
suspend fun options(subUrl: String = ""): Response
issues a options request returning a flow of it's response
patch
Link copied to clipboard
js
suspend fun patch(subUrl: String = ""): Response
issues a patch request returning a flow of it's response
post
Link copied to clipboard
js
suspend fun post(subUrl: String = ""): Response
issues a post request returning a flow of it's response
put
Link copied to clipboard
js
suspend fun put(subUrl: String = ""): Response
issues a put request returning a flow of it's response
redirect
Link copied to clipboard
js
fun redirect(value: RequestRedirect): Request
sets the redirect property of the Request
referrer
Link copied to clipboard
js
fun referrer(value: String): Request
sets the referrer property of the Request
referrerPolicy
Link copied to clipboard
js
fun referrerPolicy(value: dynamic): Request
sets the referrerPolicy property of the Request
requestMode
Link copied to clipboard
js
fun requestMode(value: RequestMode): Request
sets the requestMode property of the Request
reqWindow
Link copied to clipboard
js
fun reqWindow(value: Any): Request
sets the reqWindow property of the Request
toString
Link copied to clipboard
js
open fun toString(): String