Skip to content

Instantly share code, notes, and snippets.

@tonyc
Created July 12, 2020 22:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonyc/a1f77dc1ccd325db568a75ac6aa6dec3 to your computer and use it in GitHub Desktop.
Save tonyc/a1f77dc1ccd325db568a75ac6aa6dec3 to your computer and use it in GitHub Desktop.
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