zt
06/14/2023, 4:20 AMprivate suspend inline fun <reified T> post(endpoint: String, crossinline body: () -> Any): T {
return withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
val text = <http://httpClient.post|httpClient.post>("$API_URL/$endpoint") {
parameter("key", API_KEY)
setBody(body())
}.bodyAsText()
json.decodeFromString(serializer<T>(), text)
}
}
This doesn't work:
private suspend inline fun <reified T> post(endpoint: String, crossinline body: () -> Any): T {
return withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
<http://httpClient.post|httpClient.post>("$API_URL/$endpoint") {
parameter("key", API_KEY)
setBody(body())
}.body()
}
}
rrrrutdk rrrrutdk
06/14/2023, 5:38 AMzt
06/14/2023, 6:19 AMzt
06/14/2023, 6:20 AMZachary Siegel
06/15/2023, 3:14 AMzt
06/15/2023, 6:14 AM