fetch() error 처리하기
·
javascript
fetch() promise는 HTTP error에 의해 reject 되지 않는다. https://developer.mozilla.org/en-US/docs/Web/API/fetchfetch(api url) .then(( response ) => { if(!response.ok) { throw new Error(`error status: ${response.status}`) } return response.json() }) .then(( data ) => { // 처리 코드 console.log(data) }) .catch((error) => { // 에러 처리 코드 console.l..