Skip to content

Commit

Permalink
All contributors added
Browse files Browse the repository at this point in the history
  • Loading branch information
Son7c committed Nov 8, 2024
1 parent 3a36815 commit 5e5a32b
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions contributor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = `
Expand Down

0 comments on commit 5e5a32b

Please sign in to comment.