Can I retry the Ktor network call if body of the r...
# ktor
a
Can I retry the Ktor network call if body of the response contains
Bearer token expired
? I tried to do something like below
Copy code
retryIf { request, response ->
    response.status.value == 401 && runBlocking { response.content.readUTF8Line()?.contains("Bearer token expired") == true }
}
content
is marked internal
Is using
response.body<NetworkModel<*>>().errorMessage == "Bearer token expired"
correct approach here?
a
Can I retry the Ktor network call
That it what Auth plugin is made for
a
Can you replace the line where the
content
is accessed with the following one?
Copy code
response.bodyAsText().contains("Bearer token expired")
a
Yes did something similar
response.body<NetworkModel<*>>()
here
NetworkModel
is base network model. Thanks for the reply