Skip to content

Commit

Permalink
Update Contributors.jsx
Browse files Browse the repository at this point in the history
  • Loading branch information
RadhikaMalpani1702 committed Aug 7, 2024
1 parent cfef8f1 commit d809062
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/Pages/Contributors.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,25 @@ function Contributors() {
const [contributors, setContributors] = useState([]);

useEffect(() => {
async function fetchContributors() {
async function fetchContributors(page = 1, allContributors = []) {
try {
const response = await axios.get(
'https://api.github.com/repos/Priyaaa1/StartConnect-Hub/contributors'
`https://api.github.com/repos/Priyaaa1/StartConnect-Hub/contributors`,
{
params: {
per_page: 100,
page,
},
}
);
setContributors(response.data);

const newContributors = response.data;
if (newContributors.length > 0) {

fetchContributors(page + 1, [...allContributors, ...newContributors]);
} else {
setContributors(allContributors);
}
} catch (error) {
console.error('Error in fetching contributors:', error);
}
Expand Down

0 comments on commit d809062

Please sign in to comment.