
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.

여기 부분을 보면
let rows = data['RealtimeCityAir']['row'];
를 설정안해도 값들이 출력 되는 데,
아래 1) , 2)는 값들이 출력되지 않는 이유가 있을까요???
1)
function hey() {
let url = 'http://spartacodingclub.shop/sparta_api/seoulair';
fetch(url).then(res => res.json()).then(data => {
data.forEach(a => {
let gu_name = a['MSRSTE_NM'];
let gu_mise = a['IDEX_NM'];
console.log(gu_name, gu_mise);
});
})
}
결과 :
prac2.html:12
Uncaught (in promise) TypeError: data.forEach is not a function
at prac2.html:12:22
2)
function hey() {
let url = 'http://spartacodingclub.shop/sparta_api/seoulair';
fetch(url).then(res => res.json()).then(data => {
data.forEach(a => {
console.log(a['MSRSTE_NM'], a['IDEX_NM']);
});
})
}
결과 :
prac2.html:13
Uncaught (in promise) TypeError: data.forEach is not a function
at prac2.html:13:22
3)
function hey() {
let url = 'http://spartacodingclub.shop/sparta_api/seoulair';
fetch(url).then(res => res.json()).then(data => {
let rows = data['RealtimeCityAir']['row'];
rows.forEach(a => {
let gu_name = a['MSRSTE_NM'];
let gu_mise = a['IDEX_NM'];
console.log(gu_name, gu_mise);
});
})
}
결과 :


