Skip to content

Commit 33948b7

Browse files
committed
Add bearer token support
1 parent 493eee1 commit 33948b7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

docs/scripts/update-contributors.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,18 @@ class UserFetchError extends Error {
222222
}
223223

224224
async function fetchUserInfo(username) {
225-
const res = await fetch(`https://api.github.com/users/${username}`, {
225+
const request = new Request(`https://api.github.com/users/${username}`, {
226226
headers: {
227227
Accept: "application/vnd.github+json",
228228
"X-GitHub-Api-Version": "2022-11-28",
229229
},
230-
});
230+
})
231+
232+
if (process.env.GITHUB_TOKEN) {
233+
request.headers.set('Authorization', `Bearer ${process.env.GITHUB_TOKEN}`)
234+
}
235+
236+
const res = await fetch(request);
231237

232238
if (!res.ok) {
233239
const retryAfter = res.headers.get("retry-after"); // seconds

0 commit comments

Comments
 (0)