Skip to content

Instantly share code, notes, and snippets.

@matchilling
Last active April 8, 2018 03:33
Show Gist options
  • Save matchilling/e87cfd817d73368d0fb6 to your computer and use it in GitHub Desktop.
Save matchilling/e87cfd817d73368d0fb6 to your computer and use it in GitHub Desktop.
Simple javascript demo for https://api.chucknorris.io. Check the fiddle: https://jsfiddle.net/x94e4md8/
function getJoke() {
var req = new XMLHttpRequest();
req.onreadystatechange = function() {
if (4 == req.readyState && 200 == req.status) {
var reponse = JSON.parse(req.responseText);
console.log(reponse);
}
}
req.open('GET', 'https://api.chucknorris.io/jokes/random', true);
req.send();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment