In the previous chapters we used data from a JSON file or directly defined in the source code. While that worked for our previous recipes, it's rarely very helpful in real-world applications.
In this recipe, we will learn how to request data from an API. We will make a GET request from an API to get a JSON response. For now, however, we are only going to display the JSON in a text element. We'll be using the Fake Online REST API for Testing and Prototyping, hosted at http://jsonplaceholder.typicode.com and powered by the excellent development test API software, JSON Server (https://github.com/typicode/json-server).
We will keep this app simple so that we can focus on data management. We will have a text component that will display the response from the API and also add a button that requests the data when pressed.