Load Multiple Photos
So far, you’ve used a single photo in the application, but it really should have many photos. In this section, you’ll update the application to display multiple photos. You will learn how to search lists in a model and add error handling to the API calls from the previous chapter.
Fetch Multiple Photos
In order to fetch multiple photos, you need to change the model to use a list of photos. First, create a helpful type alias for a list of photos called Feed:
| type alias Feed = |
| List Photo |
Then, replace the photo field in Model and initialModel with a feed field that has the type Maybe Feed:
| type alias Model = |
| { feed : Maybe Feed } |
| initialModel = |
| { feed = Nothing } |
Next, ...
Get Programming Elm now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.