Last active
February 5, 2020 06:53
-
-
Save iantbutler01/f50cde9bed137a9ac5827544ec2c7a65 to your computer and use it in GitHub Desktop.
This file contains 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
defp request_page(url) do | |
case HTTPoison.get(url) do | |
{:error, res} -> | |
{:error, res.reason} | |
{:ok, res} -> | |
case res do | |
%HTTPoison.Response{status_code: 404} -> {:error, 404} | |
%HTTPoison.Response{status_code: 401} -> {:error, 401} | |
%HTTPoison.Response{status_code: 403} -> {:error, 403} | |
%HTTPoison.Response{status_code: 200, body: body} -> {:ok, body} | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment