Skip to content

Instantly share code, notes, and snippets.

@jzxhuang
Last active May 7, 2019 04:32
Show Gist options
  • Save jzxhuang/0756c1de0ccf8044d6bec625f0f93037 to your computer and use it in GitHub Desktop.
Save jzxhuang/0756c1de0ccf8044d6bec625f0f93037 to your computer and use it in GitHub Desktop.
getPost : Model -> (Result Http.Error String -> msg) -> Int -> Cmd msg
getPost model msg postId =
let
url =
model.apiUrl
++ "/posts/"
++ String.fromInt postId
++ (if model.environment == "mock" || model.environment == "test" then
".json"
else
""
)
in
Http.get
{ url = url
, expect = Http.expectJson msg decodePost
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment