Using response.body() gives me an error of "Using 'body(): ResponseBody?' is an error. moved to val" i tried removing ? but nothing works the error is in body()
override fun onResponse(call: Call, response: Response) {
val body = response.body()?.string();
println(body)
println("Sucees")
OkHttp Response To implement our JSON decoder, we need to extract the JSON from the result of the service call. For this, we can access the body via the body() method of the Response object.
It looks like you're using OkHttp 4.0.0.
The response.body()
function has been deprecated. Instead, you need to access the body as a val, like this:
override fun onResponse(call: Call, response: Response) {
val body = response.body?.string();
println(body)
println("Sucees")
}
Let me know if that helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With