Paul at Avans Breda
11/04/2024, 11:56 AMsuspend fun main() {
val client = HttpClient(CIO)
val response = client.get("<http://localhost:8080/tasks>")
println(response.bodyAsText())
}
But from the Android emulator I do not succeed. I tried by changing host to 10.0.2.2.
class TaskApi {
private val httpClient = HttpClient {
install(ContentNegotiation) {
json(Json {
encodeDefaults = true
isLenient = true
coerceInputValues = true
ignoreUnknownKeys = true
})
}
defaultRequest {
host = "10.0.2.2"
port = 8080
}
}
suspend fun getAllTasks(): List<Task> {
return httpClient.get("tasks").body()
}
...
}
When testing this from an Android emulator I get the error (see snippet).
Any clue for this problem?e5l
11/04/2024, 11:56 AMPaul at Avans Breda
11/04/2024, 12:03 PM