Skip to content

Instantly share code, notes, and snippets.

@aajjbb
Created March 28, 2017 21:40
Show Gist options
  • Save aajjbb/58f1417886cb567ddac0acc6c585641c to your computer and use it in GitHub Desktop.
Save aajjbb/58f1417886cb567ddac0acc6c585641c to your computer and use it in GitHub Desktop.
var url = "https://api.github.com/repos/awesomeWM/awesome/issues/1395/comments"
var httpRequest
window.document.onload = function makeRequest(url) {
httpRequest = new XMLHttpRequest()
if (!httpRequest) {
console.log('Browser do not support an ajax call.')
return false
}
httpRequest.onreadystatechange = callHandler
httpRequest.open('GET', url)
httpRequest.send()
}
function worker(data) {
for (var comment in data) {
body = comment.body
console.log(body)
}
}
function callHandler() {
if (httpRequest.readyState === XMLHttpRequest.DONE) {
if (httpRequest.status === 200) {
worker(JSON.parse(httpRequest.responseText))
} else {
console.log('There was a problem with the request.')
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment