Skip to content

Instantly share code, notes, and snippets.

@chanson5000
Created June 1, 2018 18:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chanson5000/5403ecbf093e0ea4b2785d0564cbdbd2 to your computer and use it in GitHub Desktop.
Save chanson5000/5403ecbf093e0ea4b2785d0564cbdbd2 to your computer and use it in GitHub Desktop.
Random Chuck Norris Joke
// Chuck Norris made me write this.
const randomChuckNorrisJoke = () => {
// Using the URL of an open Chuck Norris jokes API.
fetch('https://api.icndb.com/jokes/random')
// Retrieve data, convert to json.
.then((data) => { return data.json(); })
// This is where the joke resides in the json.
.then((json) => { console.log(json.value.joke); })
.catch((error) => { console.error(error); });
};
randomChuckNorrisJoke();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment