   # -----------------------------------
 
   # If results exist, send them, passing only the tail
-  defp _stream({:ok, %{"next" => next, "results" => [ head | tail ]}}) do
+  defp _stream({:ok, %{"next" => next, "results" => [head | tail]}}) do
     {head, {:ok, %{"next" => next, "results" => tail}}}
   end
 


  @nb_slug Application.get_env(:core, :nb_slug)
  @nb_token Application.get_env(:core, :nb_token)
  # @nb_token System.get_env("NB_TOKEN")
  @default_params %{
    limit: 100,
    access_token: @nb_token
  }

  defp process_url(url) do
    cond do
      String.starts_with? url, "/api/v1" ->
        "https://#{@nb_slug}.nationbuilder.com" <> url
      true ->
        "https://#{@nb_slug}.nationbuilder.com/api/v1/" <> url
    end
  end



  # If results don't exist, and next is not null, serve it
  defp _stream({:ok, %{"next" => next, "results" => _}}) do
    [core, params] = String.split(next, "?")
    case get(core, [query: Plug.Conn.Query.decode(params)]).body do
      {:ok, %{"next" => next, "results" => [head | tail]}} ->
        {head, {:ok, %{"next" => next, "results" => tail}}}
      true ->
        nil
    end
  end

  defp _stream({:error, message}) do
    message
  end

  # Wrap it all
