File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -17,17 +17,17 @@ export async function requestGithub(
17
17
} = { }
18
18
) {
19
19
const url = new URL ( path , "https://api.github.com" ) ;
20
- const headers = { ...( authorization && { authorization} ) , accept} ;
21
20
let response ;
21
+ let headers ;
22
22
for ( let attempt = 0 , maxAttempts = 3 ; attempt < maxAttempts ; ++ attempt ) {
23
23
if ( ratelimitReset ) {
24
24
console . warn ( `x-ratelimit-reset ${ ratelimitReset } ` ) ;
25
25
const ratelimitDelay = new Date ( ratelimitReset * 1000 ) - Date . now ( ) ;
26
26
await new Promise ( ( resolve ) => setTimeout ( resolve , ratelimitDelay ) ) ;
27
27
ratelimitDelay = null ;
28
28
}
29
- response = await fetch ( url , { headers } ) ;
30
- const headers = response . headers ;
29
+ response = await fetch ( url , { ... ( authorization && { authorization } ) , accept } ) ;
30
+ headers = response . headers ;
31
31
if ( headers [ "x-ratelimit-remaining" ] === "0" ) ratelimitReset = headers [ "x-ratelimit-reset" ] ;
32
32
if ( response . ok ) break ;
33
33
if ( headers [ "retry-after" ] ) {
@@ -38,7 +38,7 @@ export async function requestGithub(
38
38
}
39
39
throw new Error ( `failed to fetch ${ url } : ${ response . status } ` ) ;
40
40
}
41
- return { headers : response . headers , body : await response . json ( ) } ;
41
+ return { headers, body : await response . json ( ) } ;
42
42
}
43
43
44
44
export async function * listGithub ( path , { reverse = true , ...options } = { } ) {
You can’t perform that action at this time.
0 commit comments