Created
August 29, 2019 18:49
-
-
Save csandman/c0e8daa113463643cc558bbaa438c538 to your computer and use it in GitHub Desktop.
Get a random dad joke from icanhazdadjoke.com
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
const getDadJoke = async () => { | |
const dadJoke = await fetch("https://icanhazdadjoke.com/", { | |
headers: { | |
Accept: "application/json" | |
} | |
}); | |
const dadJokeJSON = await dadJoke.json(); | |
if (dadJokeJSON.status === 200) { | |
return dadJokeJSON.joke; | |
} else { | |
return "Error retrieving dad joke!" | |
} | |
}; | |
(async () => console.log(await getDadJoke()))(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment