File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,14 +15,23 @@ function getRepoPath() {
1515 return parts [ 1 ] && parts [ 2 ] ? `${ parts [ 1 ] } /${ parts [ 2 ] } ` : 'Vic-Nas/PythonSolutions' ;
1616}
1717
18+ // Users can set their own token in browser console:
19+ // localStorage.setItem('github_token', 'ghp_your_token_here')
20+ const GITHUB_TOKEN = localStorage . getItem ( 'github_token' ) || '' ;
21+
1822// Fetch folder contents
1923async function fetchFolderContents ( path ) {
2024 if ( state . folderCache [ path ] ) {
2125 return state . folderCache [ path ] ;
2226 }
2327
2428 try {
25- const res = await fetch ( `https://api.github.com/repos/${ getRepoPath ( ) } /contents/${ path } ` ) ;
29+ const headers = { } ;
30+ if ( GITHUB_TOKEN ) {
31+ headers [ 'Authorization' ] = `token ${ GITHUB_TOKEN } ` ;
32+ }
33+
34+ const res = await fetch ( `https://api.github.com/repos/${ getRepoPath ( ) } /contents/${ path } ` , { headers } ) ;
2635 if ( ! res . ok ) return null ;
2736
2837 const items = await res . json ( ) ;
You can’t perform that action at this time.
0 commit comments