JSON example has errors
pentaphobe opened this issue · 0 comments
pentaphobe commented
Errors reported in-browser via elm-reactor
All installation was using standard installation on MacOS
-- TYPE MISMATCH ------------------------------------------ examples/06-json.elm
Something is off with the body of the `getRandomCatGif` definition:
107|> Http.get
108|> { url = "https://api.giphy.com/v1/gifs/random?api_key=dc6zaTOxFJmzC&tag=cat"
109|> , expect = Http.expectJson GotGif gifDecoder
110|> }
This `get` call produces:
Decoder a -> Http.Request a
But the type annotation on `getRandomCatGif` says it should be:
Cmd Msg
-- TYPE MISMATCH ------------------------------------------ examples/06-json.elm
The 1st argument to `get` is not what I expect:
107| Http.get
108|> { url = "https://api.giphy.com/v1/gifs/random?api_key=dc6zaTOxFJmzC&tag=cat"
109|> , expect = Http.expectJson GotGif gifDecoder
110|> }
This argument is a record of type:
{ expect : b, url : String }
But `get` needs the 1st argument to be:
String
-- TYPE MISMATCH ------------------------------------------ examples/06-json.elm
The 1st argument to `expectJson` is not what I expect:
109| , expect = Http.expectJson GotGif gifDecoder
^^^^^^
This `GotGif` value is a:
Result Http.Error String -> Msg
But `expectJson` needs the 1st argument to be:
Decoder a
-- TOO MANY ARGS ------------------------------------------ examples/06-json.elm
The `expectJson` function expects 1 argument, but it got 2 instead.
109| , expect = Http.expectJson GotGif gifDecoder
^^^^^^^^^^^^^^^
Are there any missing commas? Or missing parentheses?