diff --git a/csr/src/Constant.js b/csr/src/Constant.js index 450f04b..0b10dc0 100644 --- a/csr/src/Constant.js +++ b/csr/src/Constant.js @@ -1,8 +1,10 @@ export const BASE_URL = "https://api.themoviedb.org/3/movie"; -export const TMDB_THUMBNAIL_URL = "https://media.themoviedb.org/t/p/w440_and_h660_face/"; +export const TMDB_THUMBNAIL_URL = + "https://media.themoviedb.org/t/p/w440_and_h660_face/"; export const TMDB_ORIGINAL_URL = "https://image.tmdb.org/t/p/original/"; -export const TMDB_BANNER_URL = "https://image.tmdb.org/t/p/w1920_and_h800_multi_faces/"; +export const TMDB_BANNER_URL = + "https://image.tmdb.org/t/p/w1920_and_h800_multi_faces/"; export const TMDB_MOVIE_LISTS = { popular: BASE_URL + "/popular?language=ko-KR&page=1", nowPlaying: BASE_URL + "/now_playing?language=ko-KR&page=1", diff --git a/csr/src/apis/movies.js b/csr/src/apis/movies.js new file mode 100644 index 0000000..6421631 --- /dev/null +++ b/csr/src/apis/movies.js @@ -0,0 +1,7 @@ +import { FETCH_OPTIONS, TMDB_MOVIE_LISTS } from "../Constant"; + +export const fetchMovies = async () => { + const response = await fetch(TMDB_MOVIE_LISTS.popular, FETCH_OPTIONS); + + return await response.json(); +}; diff --git a/csr/src/components/Container.jsx b/csr/src/components/Container.jsx index cfe7fc5..6361e01 100644 --- a/csr/src/components/Container.jsx +++ b/csr/src/components/Container.jsx @@ -47,18 +47,28 @@ function Container() { return (
- +

지금 인기 있는 영화

    - {lists[focusedIndex].map(({ id, title, vote_average, poster_path }) => ( -
  • - - - -
  • - ))} + {lists[focusedIndex].map( + ({ id, title, vote_average, poster_path }) => ( +
  • + + + +
  • + ) + )}
diff --git a/csr/src/hooks/useMovies.js b/csr/src/hooks/useMovies.js index 83665da..381da88 100644 --- a/csr/src/hooks/useMovies.js +++ b/csr/src/hooks/useMovies.js @@ -15,7 +15,12 @@ const useMovies = () => { const [upcomingMovies, setUpcomingMovies] = useAtom(upcomingMoviesAtom); const [focusedIndex, setFocusedIndex] = useAtom(focusedIndexAtom); - const movieLists = [nowPlayingMovies, popularMovies, topRatedMovies, upcomingMovies]; + const movieLists = [ + nowPlayingMovies, + popularMovies, + topRatedMovies, + upcomingMovies, + ]; const loadMovies = async (url, setter) => { const response = await fetch(url, FETCH_OPTIONS); diff --git a/ssr/README.md b/ssr/README.md index cdc2981..8f42037 100644 --- a/ssr/README.md +++ b/ssr/README.md @@ -25,9 +25,11 @@ npm run dev ```js export const BASE_URL = "https://api.themoviedb.org/3/movie"; - export const TMDB_THUMBNAIL_URL = "https://media.themoviedb.org/t/p/w440_and_h660_face/"; + export const TMDB_THUMBNAIL_URL = + "https://media.themoviedb.org/t/p/w440_and_h660_face/"; export const TMDB_ORIGINAL_URL = "https://image.tmdb.org/t/p/original/"; - export const TMDB_BANNER_URL = "https://image.tmdb.org/t/p/w1920_and_h800_multi_faces/"; + export const TMDB_BANNER_URL = + "https://image.tmdb.org/t/p/w1920_and_h800_multi_faces/"; export const TMDB_MOVIE_LISTS = { POPULAR: BASE_URL + "/popular?language=ko-KR&page=1", NOW_PLAYING: BASE_URL + "/now_playing?language=ko-KR&page=1", @@ -100,10 +102,14 @@ express 서버에서 `views/index.html` 파일을 활용하여 클라이언트 const templatePath = path.join(__dirname, "../../views", "index.html"); let template = fs.readFileSync(templatePath, "utf-8"); - template = template.replace("", moviesHTML); + template = template.replace( + "", + moviesHTML + ); template = template.replace( "${background-container}", - "https://image.tmdb.org/t/p/w1920_and_h800_multi_faces/" + bestMovieItem.background + "https://image.tmdb.org/t/p/w1920_and_h800_multi_faces/" + + bestMovieItem.background ); template = template.replace("${bestMovie.rate}", bestMovieItem.rate); template = template.replace("${bestMovie.title}", bestMovieItem.title); @@ -127,11 +133,15 @@ express 서버에서 `views/index.html` 파일을 활용하여 클라이언트