Created
July 12, 2020 22:52
-
-
Save tonyc/a1f77dc1ccd325db568a75ac6aa6dec3 to your computer and use it in GitHub Desktop.
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
defmodule App.Service do | |
@spec parse() :: {:ok, String.t()}, | {:error, String.t()} | |
def parse do | |
url = "https://example.com/foo.txt" | |
case HTTPoison.get(url) do | |
{:ok, %HTTPoison.response{status_code: 200, body: body}} -> | |
body # Note: Not {:ok, body} | |
_ -> | |
{:error, "whatever"} | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment