elixir_rss/lib/fetch_rss.ex
2024-10-10 22:04:34 -05:00

15 lines
291 B
Elixir

defmodule ElixirRss.Fetch do
def fetch(url) do
url
|> HTTPoison.get()
|> handle_response()
end
defp handle_response({:ok, %{status_code: 200, body: body}}) do
{:ok, body}
end
defp handle_response({_, %{status_code: _, body: body}}) do
{:error, body}
end
end