tryFetchBytes
suspend fun WindowOrWorkerGlobalScope.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?(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
Content copied to clipboard
tryFetch(method, resource, body?.let { bodyOf(it) }, headers, redirect, logOnError, abortController) { bodyAsBytes() }Content copied to clipboard
Like fetchBytes but returns null if the fetch fails or the body can't be read.