From 4ac32a8ca7f004295a945bf3858d1be40705859b Mon Sep 17 00:00:00 2001 From: Subhajit-2023-44 Date: Sat, 26 Oct 2024 19:55:09 +0530 Subject: [PATCH] done --- contributor/contributor.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/contributor/contributor.js b/contributor/contributor.js index e9b724f5..49ac4172 100644 --- a/contributor/contributor.js +++ b/contributor/contributor.js @@ -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: {} }; @@ -105,4 +117,5 @@ function scrollToContribute() { } // Initialize the page when the DOM is loaded -document.addEventListener('DOMContentLoaded', init); \ No newline at end of file +document.addEventListener('DOMContentLoaded', init); +