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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.