Skip to content

Instantly share code, notes, and snippets.

@prameshbajra
Created June 18, 2017 13:10
Show Gist options
  • Save prameshbajra/2196fc4071604e37d842148956b18aa9 to your computer and use it in GitHub Desktop.
Save prameshbajra/2196fc4071604e37d842148956b18aa9 to your computer and use it in GitHub Desktop.
Simple fetch code to generate random quote from favqs API
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