Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
Subhajit-2023-44 committed Oct 26, 2024
1 parent f280b9b commit 4ac32a8
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 4ac32a8

Please sign in to comment.