Closed CommanderTvis closed 4 years ago
You could use it the next way:
fun main() = runBlocking {
val response = "http://www.boredapi.com/api/activity".httpGetAsync()
val string = response.await().use {
it.body()?.string()
}
println(string)
}
To undestand coroutines better, I strongly recommend jetbrains hands-on: https://play.kotlinlang.org/hands-on/Introduction%20to%20Coroutines%20and%20Channels/01_Introduction
my mistake was in launching a coroutine inside runBlocking context :D
I'm pretty new to Kotlin coroutines. How can I improve this horrible code to save asynchronious request and same functional?