Skip to content

Commit 2a04299

Browse files
committed
fix?
1 parent ab6ec14 commit 2a04299

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/github.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ export async function requestGithub(
1717
} = {}
1818
) {
1919
const url = new URL(path, "https://api.github.com");
20-
const headers = {...(authorization && {authorization}), accept};
2120
let response;
21+
let headers;
2222
for (let attempt = 0, maxAttempts = 3; attempt < maxAttempts; ++attempt) {
2323
if (ratelimitReset) {
2424
console.warn(`x-ratelimit-reset ${ratelimitReset}`);
2525
const ratelimitDelay = new Date(ratelimitReset * 1000) - Date.now();
2626
await new Promise((resolve) => setTimeout(resolve, ratelimitDelay));
2727
ratelimitDelay = null;
2828
}
29-
response = await fetch(url, {headers});
30-
const headers = response.headers;
29+
response = await fetch(url, {...(authorization && {authorization}), accept});
30+
headers = response.headers;
3131
if (headers["x-ratelimit-remaining"] === "0") ratelimitReset = headers["x-ratelimit-reset"];
3232
if (response.ok) break;
3333
if (headers["retry-after"]) {
@@ -38,7 +38,7 @@ export async function requestGithub(
3838
}
3939
throw new Error(`failed to fetch ${url}: ${response.status}`);
4040
}
41-
return {headers: response.headers, body: await response.json()};
41+
return {headers, body: await response.json()};
4242
}
4343

4444
export async function* listGithub(path, {reverse = true, ...options} = {}) {

0 commit comments

Comments
 (0)