Promise 제대로 사용하는 법 — 동기값 반환 때문에 발생하는 .then 오류와 해결
들어가며
JavaScript에서 비동기 작업을 다룰 때 Promise를 일관되게 반환하는 것이 중요합니다.
함수가 Promise 대신 동기값(또는 undefined)을 반환하면 호출부에서 .then/.catch를 호출할 수 없어 런타임 오류가 납니다.
문제 사례 (실제 오류)
에러: Uncaught TypeError: User.isDuplicateLogin(...).then is not a function
원인: isDuplicateLogi...
mariii.hashnode.dev2 min read