Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create a rest endpoint to jokes #10

Closed
souenzzo opened this issue Mar 28, 2019 · 3 comments
Closed

create a rest endpoint to jokes #10

souenzzo opened this issue Mar 28, 2019 · 3 comments

Comments

@souenzzo
Copy link
Member

create a rest endpoint like /joikes that returns {"joke": "..."}
Then I will add that random joke on http://lambda-study-group.github.io/

@v0idpwn
Copy link
Member

v0idpwn commented Mar 28, 2019

isn't it better to do a request to https://raw.githubusercontent.com/lambda-study-group/lambdinha-bot/master/jokes.json and select a random joke from the output? similarly to what we do on

  def get_joke(number \\ "") do
    HTTPoison.get("https://raw.githubusercontent.com/lambda-study-group/lambdinha-bot/master/jokes.json")
    |> handle_response
    |> extract_joke(number)
  end
  
  def extract_joke(map, _number="") do
    {:ok, body} = map
    item = Enum.random body
    '#{item["joke"]}'
  end

@souenzzo
Copy link
Member Author

Nice! I will do it!

@v0idpwn
Copy link
Member

v0idpwn commented Mar 28, 2019

github has a better uptime than lambdinha 😋

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants