mkporwit
06/21/2018, 5:33 PMval result = client.get<HttpResponse> { /* your code here */ }
val data = result.content.readRemaining().readText()
Damien
06/21/2018, 9:20 PMmkporwit
06/21/2018, 11:53 PMclient.get
in a runBlocking { }
, or you can make the call from a suspend
function.mkporwit
06/21/2018, 11:56 PMval result = runBlocking {
client.get<HttpResponse> { /* your code here */ }
}
val data = result.content.readRemaining().readText()
Damien
06/22/2018, 6:36 AMe5l
06/22/2018, 6:56 AMDamien
06/22/2018, 7:00 AMmkporwit
06/22/2018, 7:03 AMval data = runBlocking{
client.get<HttpResponse>{
url(URL("<https://www.google.com>"))
}.content.readRemaining().readText()
}
e5l
06/22/2018, 7:04 AMclient.get<String>("url")
It converts the response to string automaticallymkporwit
06/22/2018, 7:05 AMreadRemaining()
is also a suspend function, so also needs to be in the runBlocking {}
mkporwit
06/22/2018, 7:06 AMmkporwit
06/22/2018, 7:08 AMval data = runBlocking{
client.get<String>("<https://www.google.com>")
}
Damien
06/22/2018, 7:13 AM