Member-only story

Building Multiplatform Weather App using KMM : Part 2 — Fetching Data

Andrea
3 min readNov 26, 2023

We already had project setup & UI for each platform from Part 1. It is now time to display the real data that we fetch from our API source. The weather data will be taken from https://api.openweathermap.org/. It is a free source but we still need to register to get API Key.

The data will be return in Json format. So in order to get more organize information, it will be nice if we have Class for this model data.

@Serializable
data class WeatherAPIResponse (
@SerialName("coord" ) var coord : Coord? = Coord(),
@SerialName("weather" ) var weather : ArrayList<Weather> = arrayListOf(),
@SerialName("base" ) var base : String? = null,
@SerialName("main" ) var main : Main = Main(),
@SerialName("visibility" ) var visibility : Int? = null,
@SerialName("wind" ) var wind : Wind? = Wind(),
@SerialName("rain" ) var rain : Rain? = Rain(),
@SerialName("clouds" ) var clouds : Clouds? = Clouds(),
@SerialName("dt" ) var dt : Int? = null,
@SerialName("sys" ) var sys : Sys? = Sys(),
@SerialName("timezone" ) var timezone : Int? = null…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Andrea
Andrea

No responses yet

Write a response