I am trying to load json from localstorage with this code:
let
val = Storage.getItem "exercises" decodeExerciseList
in
({ model | exercises = val }, Cmd.none)
but I get this error: the 5th and 6th branches of this caseproduce different types of values. - The 5th branch has this type:
( Model, Cmd Msg )
But the sixth:
( { exercise : Maybe Model.Exercise
, exercises : Task String (List Model.Exercise)
}
, Cmd msg
)
I thought maybe this could help:
case val of
succeed -> ({ model | exercises = val }, Cmd.none)
fail -> ({model | exercises = []}, Cmd.none)
but no luck. in this case, I got another error:
The 1st and 2nd branches of this caseproduce different types of values. - 1st branch has this type:
( { ..., exercises : Task String (List Model.Exercise) }, Cmd msg )
But the second one:
( { ..., exercises : List a }, Cmd msg )
so basically I'm still having a problem with Task String X instead of X.
any idea what to do here?
source
share