post
inline suspend fun <B, R> ApiFetcher.post(apiPath: 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)
Call POST on a target API path with R as the expected return type.
You can set R to Unit
if this request doesn't expect a response body.
See also tryPost, which will return null if the request fails for any reason.
Note: you should NOT prepend your path with "api/", as that will be added automatically.
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 <B> ApiFetcher.post(apiPath: String, body: B, headers: Map<String, Any>? = FetchDefaults.Headers, redirect: RequestRedirect? = FetchDefaults.Redirect, abortController: AbortController? = null, bodySerializer: SerializationStrategy<B> = serializer()): ByteArray(source)
A serialize-friendly version of post that expects a body but does not expect a serialized response.
inline suspend fun <R> ApiFetcher.post(apiPath: 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 post that has no body but expects a serialized response.