elm / http

Make HTTP requests in Elm
https://package.elm-lang.org/packages/elm/http/latest
BSD 3-Clause "New" or "Revised" License
155 stars 46 forks source link

Wrapped decode error in BadPayload is malformed #41

Closed emtenet closed 6 years ago

emtenet commented 6 years ago

I have found an issue when the decoder of expectJson fails.

A SCE (Short Correct Example) is at: https://gist.github.com/emtenet/88bb8b62689caad725314e510ef85972

It gives Json.Decode.Fail "FAIL" to Http.get. The problem with the example is you need to refer to a valid JSON file and need the appropriate cross-origin policies to be setup...

As far as I understand, the following line: https://github.com/elm/http/blob/beta-1.0.0/src/Elm/Kernel/Http.js#L108 is wrapping the decode failure as a BadPayload error but with a missing A2 produces a function rather than a Http.Error

evancz commented 6 years ago

Thank you for the extremely helpful issue! Verified the fix locally!