https://github.com/bburdette/httpjsontask
https://github.com/bburdette/httpjsontask
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/bburdette/httpjsontask
- Owner: bburdette
- License: bsd-3-clause
- Created: 2023-04-15T20:46:41.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-04-15T21:16:31.000Z (about 3 years ago)
- Last Synced: 2025-01-21T19:51:15.431Z (over 1 year ago)
- Language: Nix
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# HttpJsonTask
This [elm package](https://package.elm-lang.org/packages/bburdette/httpjsontask/latest/) 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
```