Skip to content

Commit 66c2ab8

Browse files
committed
fix: Add GitHub API version header
1 parent 64dafc0 commit 66c2ab8

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

src/index.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,22 @@ async function retry(action) {
2929
}
3030
}
3131

32-
function fetchSafely(url, token) {
32+
function fetchSafely(url, token, options = {}) {
3333
return retry(async () => {
3434
log('fetch "%s"', url)
35-
/* c8 ignore next 6 */
35+
/* c8 ignore next 7 */
3636
if (!token) token = process.env.GITHUB_TOKEN || process.env.GH_TOKEN
37-
const options = token ? {
38-
headers: {
39-
Authorization: `Bearer ${token}`
37+
if (token) {
38+
options.headers = {
39+
Authorization: `Bearer ${token}`,
40+
...options.headers
4041
}
41-
} : undefined
42+
}
43+
options = {
44+
'User-Agent': 'prantlf/grab-github-release',
45+
'X-GitHub-Api-Version': '2022-11-28',
46+
...options
47+
}
4248
const res = await fetch(url, options)
4349
/* c8 ignore next 5 */
4450
if (!res.ok) {

0 commit comments

Comments
 (0)