[Node JS] try catch / then catch
KIMJAVAN:
then/catch와 try/catch는 JavaScript에서 비동기 작업을 처리하고 오류를 관리하는 두 가지 다른 방법입니다. 이들은 Promise를 다룰 때 주로 사용됩니다. 아래에 각각의 사용 예시와 차이점을 설명하겠습니다. then/catch 예시: javascriptCopy code function getData() { fetch('https://example.com/data') .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); } then: Promise가 성공적으로 완료되었을 때 실행될 콜백 함수를 정의합니다. catch: Promi..