Skip to content

Commit 4ac32a8

Browse files
done
1 parent f280b9b commit 4ac32a8

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

contributor/contributor.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
1+
12
// Fetch data from GitHub API
23
async function fetchData() {
34
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+
}
618

719
const repoResponse = await fetch('https://api.github.com/repos/swaraj-das/Collect-your-GamingTools');
820
const repoData = await repoResponse.json();
921

10-
return { contributors: contributorsData, repoStats: repoData };
22+
return { contributors, repoStats: repoData };
1123
} catch (error) {
1224
console.error('Error fetching data:', error);
1325
return { contributors: [], repoStats: {} };
@@ -105,4 +117,5 @@ function scrollToContribute() {
105117
}
106118

107119
// Initialize the page when the DOM is loaded
108-
document.addEventListener('DOMContentLoaded', init);
120+
document.addEventListener('DOMContentLoaded', init);
121+

0 commit comments

Comments
 (0)