Created
July 21, 2018 15:11
-
-
Save rippinrobr/a911ed1759f79030f789048a705aa972 to your computer and use it in GitHub Desktop.
the getConspiracies function - retrieves a paginated list of conspiracies by category
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- getConspiracies is responsible for making the HTTP GET | |
-- call to fetch the conspiracies for a given category. The |> is a pipe operator and I'm | |
-- using to create a 'pipeline'. The Json.Decode.list conspiracyDecoder is passed to | |
-- the Http.get call as the last parameter and is responsible for turning the JSON | |
-- Array of Category object into an Elm list of Conspiracies. The List of conspiracies | |
-- from the decoder become the parameter of the DataRecieved Msg and | |
-- eventually become the content on the right of the page | |
getConspiracies : Int -> Cmd Msg | |
getConspiracies category_id = | |
Json.Decode.list conspiracyDecoder | |
|> Http.get (String.concat ["http://localhost:8088/categories/", (toString category_id), "/conspiracies"]) | |
|> Http.send ConspiracyDataReceived |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment