add pagination support for fetching contributors from Github
parent
f8a223ad53
commit
a797064fb8
@ -1,18 +1,25 @@
|
||||
function getContributors() {
|
||||
function getContributors(page) {
|
||||
if (window.jQuery) {
|
||||
const container = $('#contributors');
|
||||
jQuery.ajax('https://api.github.com/repos/mikebryant/ac-nh-turnip-prices/contributors', {})
|
||||
const container = $("#contributors");
|
||||
jQuery.ajax(`https://api.github.com/repos/mikebryant/ac-nh-turnip-prices/contributors?page=${page}`, {})
|
||||
.done(function (data) {
|
||||
if (data.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const contributorList = [];
|
||||
data.forEach((contributor, idx) => {
|
||||
contributorList.push(`<a href="${contributor.html_url}">${contributor.login}</a>`);
|
||||
contributorList.push(
|
||||
`<a href="${contributor.html_url}">${contributor.login}</a>`
|
||||
);
|
||||
if (idx < data.length - 1) {
|
||||
contributorList.push(', ');
|
||||
contributorList.push(", ");
|
||||
}
|
||||
});
|
||||
container.append(contributorList.join(''));
|
||||
container.append(contributorList.join(""));
|
||||
getContributors(page + 1);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(getContributors);
|
||||
$(document).ready(getContributors(1));
|
||||
|
Loading…
Reference in New Issue