# ktor

marios proto

10/16/2020, 11:21 AM
Hi. I am using Retrofit in an Android project, and want to migrate some parts to Ktor Client as a PoC. I am having trouble to find a way of getting the wrapped return value as Retrofit does. e.g.
suspend fun get() :Response<DataValue>
in Retrofit would give me a response code, a way to parse an error model returned, etc easily. How can I have this in Ktor? Haven't seen it in the examples, unless using the
function to the Client configuration, which I will have to configure per api call. I am pretty sure there is an easier way, but could someone point me to a good example please?

Rustam Siniukov

10/16/2020, 11:36 AM
if I understood you correctly, you are looking for
Copy code
val response = client.get<HttpResponse>(request)
val status = response.status
val content = response.receive<DataValue>

marios proto

10/16/2020, 1:22 PM
ah, thank you! will give it a try!