From 5e5a32b719e6a4f1b9253218ae13061bb0e46288 Mon Sep 17 00:00:00 2001 From: Souvik Majee Date: Fri, 8 Nov 2024 18:21:38 +0530 Subject: [PATCH] All contributors added --- contributor.js | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/contributor.js b/contributor.js index f6cd137..733f561 100644 --- a/contributor.js +++ b/contributor.js @@ -3,16 +3,33 @@ const repoName = "Ticket-Booking"; const contributorsUrl = `https://api.github.com/repos/${repoOwner}/${repoName}/contributors`; const repoUrl = `https://api.github.com/repos/${repoOwner}/${repoName}`; +async function fetchAllContributors(url) { + let contributors = []; + let page = 1; + let perPage = 100; // Max per page is 100 + + while (true) { + const response = await fetch(`${url}?per_page=${perPage}&page=${page}`); + const data = await response.json(); + + if (data.length === 0) { + break; + } + + contributors = contributors.concat(data); + page++; + } + + return contributors; +} + async function fetchContributorData() { try { - const [contributorsRes, repoRes] = await Promise.all([ - fetch(contributorsUrl), - fetch(repoUrl) + const [contributors, repoData] = await Promise.all([ + fetchAllContributors(contributorsUrl), + fetch(repoUrl).then(res => res.json()) ]); - const contributors = await contributorsRes.json(); - const repoData = await repoRes.json(); - const statsGrid = document.getElementById("statsGrid"); statsGrid.innerHTML = `