codestates / codestates/BanThing
[Error Handling] joinroom roomsId에러
- Dominant language
- TypeScript
- Stars
- 0
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
### 어떤 에러인가요?

- 에러 메시지
```
xhr.js?1a5c:210 POST http://localhost:3001/main 500 (Internal Server Error)
Error: Request failed with status code 500
at createError (createError.js?770c:16)
at settle (settle.js?8768:17)
at XMLHttpRequest.onloadend (xhr.js?1a5c:66)
```


log에 roomsId를 찍어보니 0번이 나온다. 하지만 이건 이상하다

DB에는 0번째 방이 없기 때문이다.
### 에러 핸들링 방법
- roomsId가 0이 아닐때만 post요청을 해주었다.
```
useEffect(() => {
const getPosts = async () => {
try {
if (roomsId !== 0) {
const response: AxiosResponse = await axios.post(
`http://${process.env.NEXT_PUBLIC_SERVER_ENDPOINT}/main`,
{
id: roomsId,
},
);
setData(response.data);
}
} catch (e) {
console.log(e);
}
};
getPosts();
}, [roomsId]);
```
### 에러 핸들링을 위해 참고한 레퍼런스 링크
- Memory-It 의 Error Handling 예시입니다.
[링크](https://github.com/codestates/Memory-It/issues/205)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.