问题
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")
回答1:
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!
来源:https://stackoverflow.com/questions/56913085/getting-an-error-using-body-responsebody-is-an-error-moved-to-val-with-ok