MCPcopy Create free account
hub / github.com/ChinaGodMan/UserScripts / fetchGitHubAPI

Function fetchGitHubAPI

github-co-authors/github-co-authors.user.js:495–506  ·  view source on GitHub ↗

* Simple wrapper around `fetch()` for making GitHub API requests, e.g. `fetchGitHubAPI('/repos/withastro')`. * Throws an error if the fetch does not succeed. * @param {string} endpoint GitHub API endpoint to fetch

(endpoint)

Source from the content-addressed store, hash-verified

493 * @param {string} endpoint GitHub API endpoint to fetch
494 */
495async function fetchGitHubAPI(endpoint) {
496 const response = await fetch(`https://api.github.com${endpoint}`, {
497 headers: {
498 Accept: 'application/vnd.github.v3+json',
499 Authorization: `token ${GITHUB_TOKEN}`
500 }
501 })
502 if (!response.ok) {
503 throw new Error(`GitHub API request failed: ${response.statusText}`)
504 }
505 return response.json()
506}
507
508/**
509 * Create and add the co-authors button.

Callers 1

getCoAuthorsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected