Go ProSign in

This Lesson is for Members

Subscribe today and get access to all lessons! Plus direct HD download for offline use, enhances transcripts, member comment forums, and iTunes "podcast" RSS feed. Level up your skills now!

Unlock This Lesson

Already subscribed? Sign In

Hide playlist

    Decode JSON Error/Success Data into Elm Union Types

    Sometimes your JSON may have completely different structure; for example, an HTTP API may reply with some data, or with an "error" object containing details about why the data could not be delivered. You can decode JSON with such variable structure with the oneOf function, which takes a list of decoders and tries running them against the given JSON. For further discussion on how to model server errors I recommend you also watch this lesson on handling server side validation errors

    You must be a Member to view code