Hi, I try to integrate a IAM API, we use browser login flow type, the IAM server return a Flow id to get information required to build the login form. Decoding the Ok response is perfectly fine, but if a delay occurs between the flow id request and the call the next API, the flow can be gone, so the API response if a 410, but with a JSON body containing useful information to handle user redirect…
The problem, my Msg LoginFlow (Result Http.Error LoginFlow) receive a NetworkError when handling the 410 request and my decoder are not used and the response body unavailable.
How to solve my current situation ? Thanks a lots for your help.
expectJson : (Result Http.Error a -> msg) -> Decode.Decoder a -> Expect msg
expectJson toMsg decoder =
Http.expectStringResponse toMsg <|
\response ->
case response of
BadUrl_ url ->
Err (BadUrl url)
Timeout_ ->
Err Timeout
NetworkError_ ->
Err NetworkError
BadStatus_ metadata body ->
Err (BadStatus metadata.statusCode)
GoodStatus_ metadata body ->
case Decode.decodeString decoder body of
Ok value ->
Ok value
Err err ->
Err (BadBody (Decode.errorToString err))
``
A 410 trigger the `NetworkError_` branch of my case and did not pass by a branch where I can access to status code or the body message ... maybe I'm not experienced enough to see where I can found a solution.
I’m stupid it’s not an Eml problem, but a CORS issue … so Elm is right, can not parse the body of the request … stupid me, back to my server configuration