fetchBytes

suspend fun WindowOrWorkerGlobalScope.fetchBytes(method: HttpMethod, resource: String, headers: Map<String, Any>? = FetchDefaults.Headers, body: ByteArray? = null, redirect: RequestRedirect? = FetchDefaults.Redirect, abortController: AbortController? = null): ByteArray(source)

Deprecated

We are phasing out the *Bytes version of network requests, now that we have new versions that return `Response` objects directly.

Replace with

import com.varabyte.kobweb.browser.http.bodyAsBytes
import com.varabyte.kobweb.browser.http.bodyOf
fetch(method, resource, body?.let { bodyOf(it) }, headers, redirect, abortController).bodyAsBytes()

A convenience method for fetch built around the common case of sending / receiving raw bytes.

Note that if a response is returned from the server with an error status (like permission denied, etc.), this method will throw. Otherwise, if a response does not have a body, an empty byte array will be returned.