Created
June 18, 2017 13:10
-
-
Save prameshbajra/2196fc4071604e37d842148956b18aa9 to your computer and use it in GitHub Desktop.
Simple fetch code to generate random quote from favqs API
This file contains hidden or 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
fetch("https://favqs.com/api/qotd") | |
.then((response) => { | |
return response.json(); | |
}) | |
.then((data) => { | |
let quote = data.quote.body; | |
console.log(data.quote); | |
document.write(`${quote} by ${data.quote.author}`); | |
}) | |
.catch((error) => { | |
console.log(error); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment