tryPutBytes
suspend fun tryPutBytes(apiPath: String, body: ByteArray? = null, headers: Map<String, Any>? = FetchDefaults.Headers, 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.FetchDefaults
import com.varabyte.kobweb.browser.http.bodyAsBytes
import com.varabyte.kobweb.browser.http.bodyOf
Content copied to clipboard
tryPut(apiPath, body?.let { bodyOf(it) }, headers, redirect, abortController) { bodyAsBytes() }Content copied to clipboard
Like putBytes, but returns null if the request fails or its body can't be read.
Additionally, if logOnError is set to true, any failure will be logged to the console. By default, this will be true for debug builds and false for release builds.
Note: you should NOT prepend your path with "api/", as that will be added automatically.