Skip to content

bburdette/httpjsontask

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HttpJsonTask

This elm package provides some support code for building json Tasks for use with elm/http.

Code example:

Here's one where I wanted the time of reply along with the reply itself. postJsonTask is from this lib.

sendZIMsgExp : String -> ZI.SendMsg -> (Result Http.Error ( Time.Posix, ZI.ServerResponse ) -> Msg) -> Cmd Msg
sendZIMsgExp location msg tomsg =
    postJsonTask
        { url = location ++ "/private"
        , body = Http.jsonBody (ZI.encodeSendMsg msg)
        , decoder = ZI.serverResponseDecoder
        }
        |> Task.andThen (\x -> Task.map (\posix -> ( posix, x )) Time.now)
        |> Task.attempt tomsg

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published