Solution for intro/part8

This commit is contained in:
Richard Feldman
2018-08-14 02:39:33 -04:00
parent 34b7e6e52e
commit acea5cefa0

View File

@@ -155,34 +155,13 @@ update msg model =
responseDecoder = responseDecoder =
Decode.field "user" Viewer.decoder Decode.field "user" Viewer.decoder
{- 👉 TODO: Create a Http.Request value that represents
a POST request to "/api/users"
💡 HINT 1: Documentation for `Http.post` is here:
http://package.elm-lang.org/packages/elm-lang/http/1.0.0/Http#post
💡 HINT 2: Look at the values defined above in this
let-expression. What are their types? What are the types the
`Http.post` function is looking for?
-}
request : Http.Request Viewer request : Http.Request Viewer
request = request =
Debug.todo "Call Http.post to represent a POST to /api/users/login" Http.post "/api/users" requestBody responseDecoder
{- 👉 TODO: Use Http.send to turn the request we just defined
into a Cmd for `update` to execute.
💡 HINT 1: Documentation for `Http.send` is here:
http://package.elm-lang.org/packages/elm-lang/http/1.0.0/Http#send
💡 HINT 2: The `CompletedRegister` variant defined in `type Msg`
will be useful here!
-}
cmd : Cmd Msg cmd : Cmd Msg
cmd = cmd =
Cmd.none Http.send CompletedRegister request
in in
( { model | problems = [] }, cmd ) ( { model | problems = [] }, cmd )