[JavaScript] "TypeError: Cannot read property 'then' of undefined" 해결


[JavaScript]

문제상황: 다음과 같은 코드를 작성하여, 사용자 정보를 가져오는 API를 호출한 후, 가져온 사용자 정보를 화면에 표시하려 했습니다. function getUserInfo(userId) { const apiUrl = `https://api.example.com/users/${userId}`; fetch(apiUrl) .then(response => response.json()) .then(data => { console.log(data); document.getElementById('userInfo').innerText = JSON.stringify(data); }); } getUserInfo(1);그러나 다음과 같은 에러로그가 발생했습니다. TypeError: Cannot read pro..


원문링크 : [JavaScript] "TypeError: Cannot read property 'then' of undefined" 해결