fetchBytes

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(source)

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

This method receives a request body as a byte array for the request and returns a body of bytes extracted from the response, making it good for designs where you implement a binary request / response design.

This method throws if the response fails. You can use tryFetchBytes which will return null instead.

Parameters

headers

An optional map of headers to send with the request. Note: If a body is specified, the Content-Length header will be automatically set. However, any headers set manually will always take precedence.