File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change
1
+
1
2
// Fetch data from GitHub API
2
3
async function fetchData ( ) {
3
4
try {
4
- const contributorsResponse = await fetch ( 'https://api.github.com/repos/swaraj-das/Collect-your-GamingTools/contributors' ) ;
5
- const contributorsData = await contributorsResponse . json ( ) ;
5
+ let contributors = [ ] ;
6
+ let page = 1 ;
7
+ let perPage = 100 ; // Max number of contributors per page
8
+
9
+ while ( true ) {
10
+ const contributorsResponse = await fetch ( `https://api.github.com/repos/swaraj-das/Collect-your-GamingTools/contributors?per_page=${ perPage } &page=${ page } ` ) ;
11
+ const contributorsData = await contributorsResponse . json ( ) ;
12
+
13
+ if ( contributorsData . length === 0 ) break ; // Exit loop if no more contributors
14
+
15
+ contributors = contributors . concat ( contributorsData ) ;
16
+ page ++ ; // Move to the next page
17
+ }
6
18
7
19
const repoResponse = await fetch ( 'https://api.github.com/repos/swaraj-das/Collect-your-GamingTools' ) ;
8
20
const repoData = await repoResponse . json ( ) ;
9
21
10
- return { contributors : contributorsData , repoStats : repoData } ;
22
+ return { contributors, repoStats : repoData } ;
11
23
} catch ( error ) {
12
24
console . error ( 'Error fetching data:' , error ) ;
13
25
return { contributors : [ ] , repoStats : { } } ;
@@ -105,4 +117,5 @@ function scrollToContribute() {
105
117
}
106
118
107
119
// Initialize the page when the DOM is loaded
108
- document . addEventListener ( 'DOMContentLoaded' , init ) ;
120
+ document . addEventListener ( 'DOMContentLoaded' , init ) ;
121
+
You can’t perform that action at this time.
0 commit comments