This Lesson is for PRO Members.

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


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

    Please take a moment to tell your friends:

    You must be a PRO Member to view code