Skip to content

HTTPoison integration

elixir
defmodule Example do
  def fetch_data do
    url = "https://api.apitube.io/v1/news/everything?limit=50&api_key=YOUR_API_KEY"
    
    case HTTPoison.get(url) do
      {:ok, %HTTPoison.Response{status_code: 200, body: body}} ->
        IO.puts(body)
      
      {:ok, %HTTPoison.Response{status_code: status_code}} ->
        IO.puts("Error: #{status_code}")
      
      {:error, %HTTPoison.Error{reason: reason}} ->
        IO.puts("Error: #{reason}")
    end
  end
end

Example.fetch_data()