diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 1af1f4c..e9e3fad 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -26,8 +26,8 @@ function App() { const handleFetchMovie = async () => { const response = await fetchMovie(title, page, type, year) console.log(year) - if (response.Response == 'True') { - setMovies(response.Search) + if (response.response == 'OK') { + setMovies(response.search) setTotalPages(Number(response.totalResults)) setCurrentPage(Number(page)) setLoading(false) @@ -66,15 +66,15 @@ function App() { if (sortType === 's') { sortedMovies = [...movies].sort((m1, m2) => sortAscending - ? m1.Title.localeCompare(m2.Title) - : m2.Title.localeCompare(m1.Title) + ? m1.title.localeCompare(m2.title) + : m2.title.localeCompare(m1.title) ) } if (sortType === 'y') { sortedMovies = [...movies].sort((m1, m2) => sortAscending - ? m1.Year.localeCompare(m2.Year) - : m2.Year.localeCompare(m1.Year) + ? m1.year.localeCompare(m2.year) + : m2.year.localeCompare(m1.year) ) } diff --git a/frontend/src/api/fetchMovie.ts b/frontend/src/api/fetchMovie.ts index 4ce1eae..d9ff520 100644 --- a/frontend/src/api/fetchMovie.ts +++ b/frontend/src/api/fetchMovie.ts @@ -1,4 +1,4 @@ -import { movieResponse } from '../types/movie' +import { movieObject, movieResponse } from '../types/movie' //const API_MOVIE_KEY = import.meta.env.VITE_MOVIE_API_KEY @@ -16,6 +16,7 @@ export const fetchMovie = async ( const response = await fetch(query) .then((response) => response.json()) .then((data) => { + console.log(data.search) return data }) .catch((error) => { diff --git a/frontend/src/components/MovieTableRow/index.tsx b/frontend/src/components/MovieTableRow/index.tsx index 4eb1c6b..28d2663 100644 --- a/frontend/src/components/MovieTableRow/index.tsx +++ b/frontend/src/components/MovieTableRow/index.tsx @@ -16,10 +16,10 @@ const MovieTableRow: React.FC = ({ movie, onClick }) => { return ( - + - {movie.Title} - {movie.Year} + {movie.title} + {movie.year} ) } diff --git a/frontend/src/types/movie.ts b/frontend/src/types/movie.ts index 7bbc260..a5a2ee5 100644 --- a/frontend/src/types/movie.ts +++ b/frontend/src/types/movie.ts @@ -1,15 +1,15 @@ export type movieObject = { - Poster: string - Title: string - Type: string - Year: string + poster: string + title: string + type: string + year: string imdbID: string } export type modalMovieType = movieObject | null export type movieResponse = { - Response: string + response: string totalResults: string - Search: movieObject[] + search: movieObject[] }