Let's get our hands dirty with some more Ajax calls. We'll be using the popular Star Wars API (SWAPI): https://swapi.dev/ . Take a few minutes to familiarize yourself with the documentation and how the API works.
Here's what we'll be building:
Figure 7.8 – Star Wars exploration
You can experiment with the functionality at https://packtpublishing.github.io/Hands-on-JavaScript-for-Python-Developers/chapter-7/swapi/solution-code/. Try to resist the temptation to peruse the solution code until after you've tried your hand at recreating the functionality.
Here's what our code should do:
- Display a loader on page load. This loader is provided for you as a CSS animation.
- Call the /people SWAPI endpoint to retrieve all people in the API. Hint: you will need to call SWAPI more than once to get all of the people.
- Populate the select list with the names of the people and hide the loader.
- When Go is clicked, make another...