alexfacciorusso
01/10/2019, 5:15 PMprivate val client = HttpClient {
install(JsonFeature) {
serializer = KotlinxSerializer(JSON.nonstrict)
}
}
suspend fun getWeather(cityName: String): Response<WeatherResponse> {
return try {
client.get<WeatherResponse>("<https://api.openweathermap.org/data/2.5/weather?q=$cityName>" +
"&APPID=MYOPENWEATHERAPI")
.let { Response.success(it) }
} catch (exception: Exception) {
Response.failure(exception)
}