tryPost

inline suspend fun <B, R> HttpFetcher.tryPost(resource: String, body: B, headers: Map<String, Any>? = FetchDefaults.Headers, redirect: RequestRedirect? = FetchDefaults.Redirect, abortController: AbortController? = null, bodySerializer: SerializationStrategy<B> = serializer(), responseDeserializer: DeserializationStrategy<R> = serializer()): R?(source)

Like post, but returns null if the request failed for any reason.

Additionally, if HttpFetcher.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> HttpFetcher.tryPost(resource: String, headers: Map<String, Any>? = FetchDefaults.Headers, redirect: RequestRedirect? = FetchDefaults.Redirect, abortController: AbortController? = null, responseDeserializer: DeserializationStrategy<R> = serializer()): R?(source)

A serialize-friendly version of tryPost that has no body but expects a serialized response.


inline suspend fun <B> HttpFetcher.tryPost(resource: String, body: B, headers: Map<String, Any>? = FetchDefaults.Headers, redirect: RequestRedirect? = FetchDefaults.Redirect, abortController: AbortController? = null, bodySerializer: SerializationStrategy<B> = serializer()): ByteArray?(source)

Deprecated

DO NOT IGNORE. Please change to `tryPostBytes` instead. This method will be modified soon in a backwards incompatible way, in order to support additional cases that the current form doesn't support.

Replace with

tryPostBytes(resource, body, headers, redirect, abortController, bodySerializer)

A serialize-friendly version of tryPost that expects a body but does not expect a serialized response.