[Error handling] Cannot set headers after they are sent to the client
- Dominant language
- JavaScript
- Stars
- 0
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
> ### 어떤 에러인가요?
> 서버 쪽 로그인, 로그아웃, 회원가입, 회원탈퇴 기능 구현 위한 코드 작성 후 서버 실행 후 포스트맨을 통한 테스트 시 확인되었던 문제입니다.
>
> ### 에러 메시지
> ```shell
> $ Cannot set headers after they are sent to the client
> ```
>
> ### 에러 핸들링 방법
> if문 안에 res로 응답을 바로 주지 않고 return res 로 응답코드 작성 시 해결되었습니다.
>
> ```js
> if(!email || !password || !nickname) {
> res.status(422).json({ message: "Insufficient Parameters Supplied!" });
> };
> ```
>
> 위 코드에서 res.status() 를 return res.status() 로 변경 하니 해결되었습니다.
>
> ### 에러 핸들링을 위해 참고한 레퍼런스 링크
> [링크](https://velog.io/@yhe228/ERRHTTPHEADERSSENT-Cannot-set-headers-after-they-are-sent-to-the-client)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.