resolve
-
fetch의 함정(?); fetch는 resolve된 프로미스다.Web/Error & Fix 2022. 6. 11. 21:39
드디어 3주에 걸친 자스 기초 스터디가 끝나고 평화롭게 깜지를 적고 있었던 중 동기 분의 질문이 올라왔다. Q. "fetch의 url이 잘못되었는데, catch가 바로 실행되지 않고 then 안의 console.log가 실행돼요!" const f = fetch('https://raw.githubusercontent.com/paullabkorea/coronaVaccinationStatus/main/data/data.jsonㄹㄴㅇ') .then(data => { console.log('데이터 받기 성공!') const jsonData = data.json() return jsonData }) .then(json => { json.forEach(item => { console.log(item) const h2..