This page covers Tutorial v2. Elm 0.18.
Models
We want to store the response from the server in the models instead of the hardcoded list of players we have now.
In src/Models.elm, include a new import and change the type of players:
...
import RemoteData exposing (WebData)
type alias Model =
{ players : WebData (List Player)
}
initialModel : Model
initialModel =
{ players = RemoteData.Loading
}
...
- We changed the type of
playersfromList PlayertoWebData (List Player). This typeWebDatawill contain the list of players when we get a successful response from the API. - Our initial
playersattribute will beRemoteData.Loading, as it says this indicates that the resource is loading.