Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
r = new XMLHttpRequest
r.open 'GET', 'https://newsapi.org/v2/top-headlines?' + 'country=us&' + 'apiKey=******************************', true
r.responseType = 'json'
r.onreadystatechange = ->
if(r.status >= 400)
print "Error #{r.status}"
if(r.readyState == XMLHttpRequest.DONE && r.status == 200)
print r.response.articles[0].title
r.send()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment