I certainly have some catching up to do on understanding Recursion. I've got this
def query_url(id,page_number) do
returned_response = HTTPoison.get! "https://some_web_page/#{id}/? pageNumber=#{page_number}"
case returned_response.status_code do
200 ->
{:ok,returned_response.body}
_ ->
{:error,:not_found}
end
end
... and
def recursive_function(id,page_number) do
case query_url(id,page_number) do
{:ok,response} ->
non_recusive_function(response)
recursive_function(id,page_number + 1)
{:error, :not_found} ->
IO.puts "Exited"
end
end
Assuming recursive_function(1234,1), It was my thinking that the recursive function would exit once query_url/2 returns {:error, :not_found}, but that's not the case, the recursive call does not exit.
All I'm trying to do is make a get request to a particular url, carry out some actions as long as 200 status was returned and exit once a non 200 status is returned.
IO.inspecting every return value to make sure you do get the error case back?