Last active
August 2, 2023 06:57
-
-
Save wolfiex/2632b36250600d193108c044cc6d3b24 to your computer and use it in GitHub Desktop.
Fetch files from github.
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
/* Author: Daniel Ellis 2022 */ | |
export async function getgit (owner, repo, path) { | |
// A function to fetch files from github using the api | |
let data = await fetch ( | |
`https://api.github.com/repos/${owner}/${repo}/contents/${path}` | |
) | |
.then (d => d.json ()) | |
.then (d => | |
fetch ( | |
`https://api.github.com/repos/${owner}/${repo}/git/blobs/${d.sha}` | |
) | |
) | |
.then (d => d.json ()) | |
.then (d => JSON.parse (atob (d.content))); | |
return data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment