Retrieving data from a remote API
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access