Created
June 1, 2018 18:08
-
-
Save chanson5000/5403ecbf093e0ea4b2785d0564cbdbd2 to your computer and use it in GitHub Desktop.
Random Chuck Norris Joke
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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