In this chapter, we learned how to Create, Read, Update, and Delete (CRUD) resources on a server from an Elm app. The built-in modules — Http, Json.Decode, and Json.Encode — provide everything we need for creating CRUD requests. We discovered a third-party package called NoRedInk/elm-decode-pipeline that provides a much better syntax for decoding JSON. It is also more powerful than Json.Decode allowing us to easily decode an object with more than eight fields.

Another third-party package called krisajenkins/remotedata made us realize that an HTTP request can be in one of these four states at any given time: NotAsked, Loading, Success, and Failure. We used that knowledge to improve our app’s UI by properly handling those states.

As we started adding more features to our app, we realized that we needed to split our code into smaller modules. We followed a simple structure recommended by Kris Jenkins — the author of RemoteData.

We built separate pages for creating, updating, and retrieving resources from a server. The Navigation and UrlParser modules helped us route users to correct pages based on paths.

In the next chapter, we’ll learn how to interact with JavaScript code using ports.

Back to top

New chapters are coming soon!

Sign up for the Elm Programming newsletter to get notified!

* indicates required