🌐
Ktor Client Pitfalls
Find the bugs in each code snippet
←→NavigateAShow remainingRReset
🎯Bug Formula: What's wrong → What breaks for the user → The fix → The trade-off
Find the bugs in each code snippet
1class HotelApiService {23 suspend fun searchHotels(query: String): List<Hotel> {4 val client = HttpClient(CIO) {5 install(ContentNegotiation) {6 json(Json { ignoreUnknownKeys = true })7 }8 }910 val response: List<Hotel> = client.get("https://api.example.com/hotels") {11 parameter("q", query)12 }.body()1314 return response15 }1617 suspend fun getHotelDetails(id: String): Hotel {18 val client = HttpClient(CIO) {19 install(ContentNegotiation) {20 json(Json { ignoreUnknownKeys = true })21 }22 }2324 return client.get("https://api.example.com/hotels/$id").body()25 }26}Find the bugs in each code snippet
1class HotelApiService {23 suspend fun searchHotels(query: String): List<Hotel> {4 val client = HttpClient(CIO) {5 install(ContentNegotiation) {6 json(Json { ignoreUnknownKeys = true })7 }8 }910 val response: List<Hotel> = client.get("https://api.example.com/hotels") {11 parameter("q", query)12 }.body()1314 return response15 }1617 suspend fun getHotelDetails(id: String): Hotel {18 val client = HttpClient(CIO) {19 install(ContentNegotiation) {20 json(Json { ignoreUnknownKeys = true })21 }22 }2324 return client.get("https://api.example.com/hotels/$id").body()25 }26}