pagination finished

Co-authored-by: Sindre Kjelsrud <kjelsrudsindre@gmail.com>
This commit is contained in:
haraldnilsen 2023-09-05 13:19:25 +02:00
parent 4427c2efc0
commit a604592622

View file

@ -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)