From d0c1b7a4932d43f51757110b123f84a21d8c9d81 Mon Sep 17 00:00:00 2001 From: Tue Date: Wed, 6 Oct 2021 15:43:05 -0400 Subject: [PATCH] Removing unnecessary math to calculate maxpages --- frontend/src/components/Home.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/Home.js b/frontend/src/components/Home.js index f4d6bda..6b87205 100644 --- a/frontend/src/components/Home.js +++ b/frontend/src/components/Home.js @@ -83,7 +83,7 @@ export default function Home() { useEffect(() => { let url = `${API_HOST}/leads?page=${page}&perpage=${perpage}`; - const n_pagesUrl = `${API_HOST}/leads/n_pages`; + const n_pagesUrl = `${API_HOST}/leads/n_pages?perpage=${perpage}`; if (search) { url += `&search=${search}`; } @@ -108,9 +108,7 @@ export default function Home() { headers: headers, }) .then((response) => checkForErrors(response)) - .then((data) => - setMaxPages(Math.ceil((data.pages * data.query.perpage) / perpage)) - ) + .then((data) => setMaxPages(data.pages)) .catch((error) => console.error(error.message)); }, [page, perpage, maxpages, search]);