Skip to content

Commit

Permalink
Merge pull request #694 from Subhajit-2023-44/contributors
Browse files Browse the repository at this point in the history
Improve Contributors page done ! #650
  • Loading branch information
swaraj-das authored Oct 27, 2024
2 parents 565b7ef + 4ac32a8 commit 3122a8e
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions contributor/contributor.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@

// Fetch data from GitHub API
async function fetchData() {
try {
const contributorsResponse = await fetch('https://api.github.com/repos/swaraj-das/Collect-your-GamingTools/contributors');
const contributorsData = await contributorsResponse.json();
let contributors = [];
let page = 1;
let perPage = 100; // Max number of contributors per page

while (true) {
const contributorsResponse = await fetch(`https://api.github.com/repos/swaraj-das/Collect-your-GamingTools/contributors?per_page=${perPage}&page=${page}`);
const contributorsData = await contributorsResponse.json();

if (contributorsData.length === 0) break; // Exit loop if no more contributors

contributors = contributors.concat(contributorsData);
page++; // Move to the next page
}

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

return { contributors: contributorsData, repoStats: repoData };
return { contributors, repoStats: repoData };
} catch (error) {
console.error('Error fetching data:', error);
return { contributors: [], repoStats: {} };
Expand Down Expand Up @@ -105,4 +117,5 @@ function scrollToContribute() {
}

// Initialize the page when the DOM is loaded
document.addEventListener('DOMContentLoaded', init);
document.addEventListener('DOMContentLoaded', init);

0 comments on commit 3122a8e

Please sign in to comment.