What is the correct way to call the OkHTTP client inside a Coroutine?
CoroutineScope(IO).launch {
val request = Request.Builder()
.url("${host}/dots")
.build()
val client = OkHttpClient()
client.newCall(request).enqueue(object: Callback{
override fun onFailure(call: Call, e: IOException) {
isConnected.postValue(false)
}
override fun onResponse(call: Call, response: Response) {
val loadingStr = response.body()?.string().toString()
loadingStrings = loadingStr
Log.i("My_Error",loadingStrings)
}
})
}
In the onResponse the loadingStr variable shows warning for string() saying inappropriate blocking method called. Please tell me the correct way to do the same.