Hey germain, On Thu, Jun 16, 2016 at 9:52 AM, germain <germainde...@gmail.com> wrote: > > HOWEVER I just get the value field of the response and nothing else > > UnexpectedPayload "Expecting an object with a field named `fakeInt` but > instead got: {\"data\":{\"seatNo\":100,\"occupied\":true,\"id\":67}}" > > What's wrong?
If you're looking to handle UnexpectedPayload messages, you'll need to include the Response in the error type: withResponse : JsonDecode.Decoder a -> Task.Task Http.RawError Http.Response -> Task.Task (Maybe Http.Response, Http.Error) a withResponse decoder task = let decoded response = Http.fromJson decoder (Task.succeed response) in -- Task.mapError promoteError task `Task.andThen` decoded Task.mapError (\rawErr -> (Nothing, promoteError rawErr)) task `Task.andThen` (\resp -> Task.mapError (\err -> (Just resp, err)) (decoded resp)) Cheers, William --- https://jb55.com -- 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 elm-discuss+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.