* @param {string} path * @param {{[string: string]: string|Object}=} options * @return {!Promise }
(path, options)
| 26 | * @return {!Promise<Object[]|Object>} |
| 27 | */ |
| 28 | async 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 |
no test coverage detected