TIL - 2021.05.13

DD-TIL·2021년 5월 30일
0

TIL

목록 보기
75/254

Today Ariticle

Today Commit Review

깃 commit 캡쳐 이미지


Today I Learned

  • fetch()로 부터 반환되는 Promise객체는 HTTP error 상태를 reject하지 않는다. 그래서 HTTP 요청 중 에러가 발생해도 catch로 잡지 못하기 때문에, response의 ok 속성을 체크해야한다.
fetch(url)
  .then((res)=>{
	if(!res.ok) {
    	throw new Error('error')
    }
  return res.json();
}).catch(e=>{
	console.error(e)
}

Today Review

profile
TIL을 작성하기 위한 공간입니다. 본진은 => https://velog.io/@jjunyjjuny

0개의 댓글