Web/Error & Fix
-
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..
-
드롭다운 구현에서 blur와 click 이벤트, 그리고 CSS transition의 영향..Web/Error & Fix 2022. 5. 17. 15:00
드롭다운을 구현하는 중에 바깥을 클릭했을 때 드롭다운이 사라지게 하기 위해서(더 나은 UX..! 항상 사용자 입장에서 생각하기!!!) 'blur'라는 이벤트를 추가했다. 이렇게 const selectBox = document.querySelector('.select-box'); const dropbox = document.querySelector('.dropbox'); const dropboxOpt = document.querySelectorAll('li'); const OptText = document.querySelectorAll('.dropbox-opt'); selectBox.addEventListener('click',function (){ dropbox.classList.toggle('on');..