Im trying to get the return result to return a string, I believe this might be a noob question but I'm very new to kotlin so please don't be harsh. All solutions welcome!
private val client = OkHttpClient()
fun getRequest(id: String) {
val url = "http://localhost:8000/api/v1/discord?discordid=$id"
val request = Request.Builder()
.url(url)
.header("User-Agent", "OkHttp Bot")
.build()
client.newCall(request).enqueue(object : Callback {
override fun onFailure(call: Call, e: IOException) {
println("Error: ${e.message}")
}
override fun onResponse(call: Call, response: Response) {
response.use {
if (!response.isSuccessful) throw IOException("Unexpected code $response")
var result = response.body!!.string()
return result
}
}
})
}