Let's get some hands-on practice with this API. What we're going to do is fairly inelegant for the moment, but it will show us how to use asynchronous behavior to our advantage.
You should expect to see something like this:
Figure 4.8 – SWAPI Promises result
Keep in mind that since we're using Promises and have to iterate over the films array, the order of films may vary. You can choose to order them by film number if you wish.
This lab will require nested Promises and some syntaxes we haven't covered yet, so give yourself plenty of time to experiment if you'd like to do this lab:
- Starter code: https://github.com/PacktPublishing/Hands-on-JavaScript-for-Python-Developers/tree/master/chapter-4/ajax-lab/starter-code
- Solution code: https://github.com/PacktPublishing/Hands-on-JavaScript-for-Python-Developers/tree/master/chapter-4/ajax-lab/solution-code
As with any lab, keep in mind that the solution code won't match your code, but is meant...