kimsojung318 / movie-app

1 stars 0 forks source link

#4 Landing Page 만들기 (1) #5

Open kimsojung318 opened 3 years ago

kimsojung318 commented 3 years ago
  1. Template 1) 파일 생성 : LandingPage\Sections\MainImage.js

    • Landing Page에 표시되면 가장 인기 있는 영화 정보가 게시된다.

    2) EndPoint 생성 : LandingPage.js const endpoint =${API_URL}movie/popular?api_key=${API_KEY}& language=en-US&page=1;

    3) 공통 URL 상수 처리 : Config.js

        export const API_URL = "https://api.themoviedb.org/3/";
        export const API_KEY = "52dcd192673a08227df3669a120cb168";
        export const IMAGE_BASE_URL = "http://image.tmdb.org/t/p/";
kimsojung318 commented 3 years ago
  1. 오류 1) 내용

    • 영화 정보를 가져오기 전에 랜더링을 했기 때문에 오류 발생
    • TypeError: Cannot read property 'backdrop_path' of null

    2) 해결방법

        {MainMoviesImage &&
            <MainImage image={`${IMAGE_BASE_URL}w1280${MainMoviesImage.backdrop_path}`} />
        }