MCPcopy
hub / github.com/ampproject/amphtml / githubFetch

Function githubFetch

build-system/tasks/sweep-experiments/cleanup-branches.js:28–45  ·  view source on GitHub ↗

* @param {string} path * @param {{[string: string]: string|Object}=} options * @return {!Promise }

(path, options)

Source from the content-addressed store, hash-verified

26 * @return {!Promise<Object[]|Object>}
27 */
28async function githubFetch(path, options) {
29 const url = `https://api.github.com/repos/${org}/${repo}/${path}`;
30 const response = await fetch(url, {
31 method: 'GET',
32 headers: {
33 'Content-Type': 'application/json',
34 'User-Agent': 'amphtml',
35 'Accept': 'application/vnd.github.v3+json',
36 'Authorization': `token ${env('GITHUB_TOKEN')}`,
37 },
38 ...options,
39 });
40 if (!response.ok) {
41 const text = await response.text();
42 throw new Error(`${url}\n${text}`);
43 }
44 return response.json();
45}
46
47/**
48 * @param {(number) => string} getPagePath

Callers 3

getAllPaginatedFunction · 0.85
getBranchPullFunction · 0.85
closePullRequestFunction · 0.85

Calls 4

fetchFunction · 0.85
envFunction · 0.70
textMethod · 0.45
jsonMethod · 0.45

Tested by

no test coverage detected