Fetching data from a network endpoint
In this section, we will use The Cat API (https://thecatapi.com/). This RESTful API offers us vast data about, well… cats.
Setting up Ktor and internet permissions
To get started, we will create a new project. To allow our app to make network calls, we have to grant our app the internet access install-time permission. We can do this by adding the following code to your AndroidManifest.xml file, right before the Application tag:
<uses-permission android:name="android.permission.INTERNET" />
Next, we need to set up our app so that it includes Ktor. Ktor helps us generate Uniform Resource Locators (URLs), which are the addresses of the server endpoints we want to access. It also makes decoding JSON payloads into Kotlin data structures easier by providing integration with several parsing libraries. Sending data to the server is also easier with Ktor, as it helps with encoding the requests from Kotlin data structures...