Are you able to confirm in the developer console or Postman or some other
tool that you are actually getting a 401 from the server?

I'm getting 400 and 401 just fine from my servers and Elm is encoding them
just fine as a BadStatus.



On Sun, Dec 3, 2017 at 5:36 AM, Michal Blazejczyk <
[email protected]> wrote:

> Hi all,
>
> I'm just beginning to get into Elm, and I encountered an issue.  My Elm
> app is making a POST request (Http.post) and when the server returns 400 or
> 401, I get NetworkError instead of BadStatus which means that I cannot
> distinguish between error codes.
>
> Looking at Javascript generated by the Elm compiler, I see:
>
> function toTask(request, maybeProgress)
> {
>   // ...
>   xhr.addEventListener('error', function() {
>     callback(_elm_lang$core$Native_Scheduler.fail({ ctor: 'NetworkError'
> }));
>   });
>   xhr.addEventListener('timeout', function() {
>     callback(_elm_lang$core$Native_Scheduler.fail({ ctor: 'Timeout' }));
>   });
>   xhr.addEventListener('load', function() {
>     callback(handleResponse(xhr, request.expect.responseToResult));
>   });
>   // ...
> }
>
>
> For 400 and 401 responses, the browser triggers the listener for 'error'.
> Is there a way to have Elm generate a BadStatus in this case?
>
> Best,
> Michal
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to