From a60459262282b4f54bf19c3ed4c17b9a32f986a7 Mon Sep 17 00:00:00 2001 From: haraldnilsen Date: Tue, 5 Sep 2023 13:19:25 +0200 Subject: [PATCH] :sparkles: pagination finished Co-authored-by: Sindre Kjelsrud --- src/App.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index b5dc10f..eea2ade 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -12,7 +12,9 @@ function App() { const [totalPages, setTotalPages] = useState(0) useEffect(() => { - fetch(`http://www.omdbapi.com/?apikey=${API_MOVIE_KEY}&s=spider-man`) + fetch( + `http://www.omdbapi.com/?apikey=${API_MOVIE_KEY}&s=spider-man&page=${currentPage}` + ) .then((response) => response.json()) .then((data) => { setMovies(data.Search) @@ -20,7 +22,7 @@ function App() { }) .then(() => setLoading(false)) .catch((error) => console.log(error)) - }, []) + }, [currentPage]) const calculatePages = (totalResults: number): number => { return Math.round(totalResults / 10)