tryPatch
inline suspend fun <B, R> ApiFetcher.tryPatch(apiPath: String, headers: Map<String, Any>? = FetchDefaults.Headers, body: B? = null, redirect: RequestRedirect? = FetchDefaults.Redirect, abortController: AbortController? = null, bodySerializer: SerializationStrategy<B> = serializer(), responseDeserializer: DeserializationStrategy<R> = serializer()): R?(source)
Like patch, but returns null if the request failed for any reason.
Additionally, if ApiFetcher.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.
Parameters
body
The body to send with the request. Make sure your class is marked with @Serializable or provide a custom bodySerializer.
inline suspend fun <R> ApiFetcher.tryPatch(apiPath: String, headers: Map<String, Any>? = FetchDefaults.Headers, body: ByteArray? = null, redirect: RequestRedirect? = FetchDefaults.Redirect, abortController: AbortController? = null, responseDeserializer: DeserializationStrategy<R> = serializer()): R?(source)
A serialize-friendly version of tryPatch that doesn't put any type constraints on the body.
This is useful if your request doesn't require a body to be included, so there shouldn't be a need to specify a body type constraint in that case, or if it is easier to use a custom, handcrafted byte array message instead.