Package-level declarations

Types

Link copied to clipboard

A class which can be used to abort an API request after it was made.

Link copied to clipboard

Default values for fetch (or methods that delegate to fetch).

Link copied to clipboard
class HttpFetcher(window: Window)

A class with a slightly friendlier API than using Window.fetch directly by providing HTTP method helper methods.

Link copied to clipboard
Link copied to clipboard
class ResponseException(val response: Response, val bodyBytes: ByteArray?) : Exception

An exception that gets thrown if we receive a response whose code is not in the 200 (OK) range.

Properties

Link copied to clipboard

Functions

Link copied to clipboard
suspend fun Window.fetch(method: HttpMethod, resource: String, headers: Map<String, Any>? = FetchDefaults.Headers, body: ByteArray? = null, redirect: RequestRedirect? = FetchDefaults.Redirect, abortController: AbortController? = null): ByteArray
Link copied to clipboard
suspend fun Window.fetchBytes(method: HttpMethod, resource: String, headers: Map<String, Any>? = FetchDefaults.Headers, body: ByteArray? = null, redirect: RequestRedirect? = FetchDefaults.Redirect, abortController: AbortController? = null): ByteArray

A Kotlin-idiomatic version of the standard library's Window.fetch function.

Link copied to clipboard
suspend fun Window.tryFetch(method: HttpMethod, resource: String, headers: Map<String, Any>? = FetchDefaults.Headers, body: ByteArray? = null, redirect: RequestRedirect? = FetchDefaults.Redirect, logOnError: Boolean = false, abortController: AbortController? = null): ByteArray?
Link copied to clipboard
suspend fun Window.tryFetchBytes(method: HttpMethod, resource: String, headers: Map<String, Any>? = FetchDefaults.Headers, body: ByteArray? = null, redirect: RequestRedirect? = FetchDefaults.Redirect, logOnError: Boolean = false, abortController: AbortController? = null): ByteArray?

Like fetchBytes but returns null if the fetch fails for any reason instead of throwing.