-
-
Save mysteriouspants/351e85b330d3fd6d9b73 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
defmodule Life do | |
def start do | |
spawn(fn -> listen() end) | |
end | |
defp listen() do | |
receive do | |
{:add, url} -> | |
loop(url) | |
end | |
end | |
defp loop(url) do | |
IO.puts "hey" | |
resp = HTTPoison.get! url | |
json_body = Poison.decode! resp.body | |
list = json_body["data"] |> Enum.map fn(x) -> x["images"]["standard_resolution"]["url"] end | |
send self(), {:add, json_body["pagination"]} | |
IO.puts list_perm | |
loop(list_perm ++ list) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment