@collected/github-fetch
v0.0.1
Published
Fetch content directly from a GitHub repo
Downloads
3
Readme
Collected GitHub Fetch
Install
npm add @collected/github-fetch
import {
fetchGitHubRepoRefs,
findHEADInRefs,
fetchGitHubRepoContent,
} from '@collected/github-fetch'
const gitHubOwner = 'cool-calm'
const repoName = 'collected-press'
const refsGenerator = fetchGitHubRepoRefs(gitHubOwner, repoName)
const head = findHEADInRefs(refsGenerator())
if (!head) {
throw Error('No HEAD ref')
}
const response: Response = await fetchGitHubRepoContent(
gitHubOwner,
repoName,
head.sha,
'README.md',
)
// Use response:
// e.g. forward from your own server
// e.g. await response.text()
// e.g. markdownToHTML(await response.text())