Skip to content

Instantly share code, notes, and snippets.

@codeaholicguy
Created August 26, 2020 11:05
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 codeaholicguy/323e8b7e2a022f2193cd8d8f1b1d7e21 to your computer and use it in GitHub Desktop.
Save codeaholicguy/323e8b7e2a022f2193cd8d8f1b1d7e21 to your computer and use it in GitHub Desktop.
const axios = require("axios");
const fs = require("fs");
const getQuote = async () => {
try {
const { data } = await axios.get("https://quotes.rest/qod?language=en");
const quote = data.contents.quotes[0].quote;
const author = data.contents.quotes[0].author;
console.log("new quote", `"${quote}"`);
return {
quote,
author,
};
} catch (err) {
console.error(err.message);
return {};
}
};
const generate = async () => {
const { quote, author } = await getQuote();
if (!quote) return;
fs.writeFileSync("README.md", `_**${quote}**_\n\n${author}`);
};
generate();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment