Last active
October 26, 2021 00:20
-
-
Save gaurangrshah/ad89eec156d74dad8b58d8f566cb8025 to your computer and use it in GitHub Desktop.
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
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