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(
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
4444export async function * listGithub ( path , { reverse = true , ...options } = { } ) {
You can’t perform that action at this time.
0 commit comments