Skip to content

Instantly share code, notes, and snippets.

@gaurangrshah
Last active October 26, 2021 00:20
Show Gist options
  • Save gaurangrshah/ad89eec156d74dad8b58d8f566cb8025 to your computer and use it in GitHub Desktop.
Save gaurangrshah/ad89eec156d74dad8b58d8f566cb8025 to your computer and use it in GitHub Desktop.
async function getGist(gistId, filename) {
const url = `https://api.github.com/gists/${gistId}`;
try {
const response = await fetch(url);
const json = await response.json();
return JSON.parse(json.files[filename].content)
} catch (err) {
console.error(err)
}
}
// USAGE:
// (async function() {
// let payments = await getGist(paymentsGistId, 'payments.json');
// console.log(payments.length);
// payments = payments.reduce((acc, curr) => {
// const key = `Q${moment(curr.)}`
// });
// })();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment