I am working on an Elm task to decode the JSON from API. The problem I met is the decoder I've written is not matched the JSON so I want to show the error. But I cannot convert the error message from #Http.Error#
type to #String#
type in Elm with toString
function. Here is the code:
type Model =
Loading
| Failure String
| Success (List WishlistItem)
| NoData
update msg model =
case msg of
GotItems (Ok result) ->
(Success result.data.wish_list_items, Cmd.none)
GotItems (Err errorString) ->
(Failure (toString errorString), Cmd.none)
▔▔▔▔▔▔▔▔
The error was:
NAMING ERROR - I cannot find a
toString
variable:168| (Failure (toString errorString), Cmd.none)
I try with Basics.toString
but it not work. Can anyone help me to point out the problem?
P/s 1: I am using Elm 0.19
P/s 2: And is there another way to find the problem when decoding the JSON with NoRedInk/elm-decode-pipeline
package? I tried with Debug.log
but it just printed the function
and have no idea how to debug. It's really hard to know where is the problem.