콘솔에 movies.results 하면 나오는데 movies.results[1] 하면 왜 Uncaught TypeError: Cannot read properties of undefined (reading '1') 에러 뜰까요
1.2K
1
1
0
닥터핸·2022-04-30
movies.results[1]에 접근하기 전에 다음과 같이 처리해보시기 바랍니다.
if(movies.results && movies.results.length > 0) {
console.log(movies.results[0]);
}
movies.results 값을 아직 가져오지 않은 상태에서 접근하기 때문에
...