From db1aaea08133f0165f4103bc037638a9d48b9f68 Mon Sep 17 00:00:00 2001 From: James Glenn Date: Thu, 30 Apr 2020 13:48:30 -0500 Subject: [PATCH] pull out 100 per page into its own const --- js/contributors.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/js/contributors.js b/js/contributors.js index 1a4f7a7..8961f1e 100644 --- a/js/contributors.js +++ b/js/contributors.js @@ -1,7 +1,8 @@ function getContributors(page) { + const PER_PAGE = 100 if (window.jQuery) { const container = $('#contributors'); - jQuery.ajax(`https://api.github.com/repos/mikebryant/ac-nh-turnip-prices/contributors?page=${page}&per_page=100`, {}) + jQuery.ajax(`https://api.github.com/repos/mikebryant/ac-nh-turnip-prices/contributors?page=${page}&per_page=${PER_PAGE}`, {}) .done(function (data) { const contributorList = []; data.forEach((contributor, idx) => { @@ -15,8 +16,8 @@ function getContributors(page) { } }); container.append(contributorList.join('')); - // If the length of the data is < 100, we know we are processing the last page of data. - if (data.length < 100) return; + // If the length of the data is < PER_PAGE, we know we are processing the last page of data. + if (data.length < PER_PAGE) return; getContributors(page + 1); }); }