decode

inline suspend fun <T> ContentSource.decode(bodyDeserializer: DeserializationStrategy<T> = serializer()): T?(source)

A serialization-aware convenience method layered on top of ContentSource.text.

An exception will be thrown if the body type cannot be deserialized (either due to body text that is not valid JSON or valid JSON that cannot be converted into the requested type).

See also the ApiFetcher extension methods provided by this library for examples of how to send requests with a serialized body, e.g. window.api.post<ExampleRequest, ExampleResponse>(body = ...).