使用response.body()给我一个错误:“使用'body():ResponseBody?'错误。移至val”,我尝试删除?但没有任何效果,错误在body()
override fun onResponse(call: Call, response: Response) {
val body = response.body()?.string();
println(body)
println("Sucees")
答案 0 :(得分:2)
您似乎正在使用OkHttp 4.0.0。
response.body()
函数已被弃用。相反,您需要以val形式访问主体,如下所示:
override fun onResponse(call: Call, response: Response) {
val body = response.body?.string();
println(body)
println("Sucees")
}
让我知道是否有帮助!