Skip to content

Commit

Permalink
sdp-tech#523 fix : community url exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
youngsikkk committed Oct 10, 2023
1 parent 392073f commit f4d4773
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/Community/CommunityDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ export default function CommunityDetail({ board, id, format }) {
try {
const response_detail = await request.get(`/community/posts/${id}`);
setDetail(response_detail.data);
console.log(response_detail);
setLike(response_detail.data.likes);
setLoading(false);
if (response_detail.data.board != board) navigate("/notexistpage");
}
catch(e) {
navigate("/notexistpage");
Expand Down
13 changes: 10 additions & 3 deletions src/pages/SpotCommunity.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,18 @@ export default function SpotCommunity() {
const request = Request(navigate);
const [format, setFormat] = useState();
const getFormat = async () => {
const response = await request.get(`/community/boards/${params.board}/`);
setFormat(response.data);
setLoading(false);
try {
const response = await request.get(`/community/boards/${params.board}/`);
setFormat(response.data);
setLoading(false);
}
catch (e) {
navigate(`/notexistpage`);
}
}

if (params.board > 4) {navigate(`/notexistpage`)}

useEffect(() => {
getFormat();
}, [params.board]);
Expand Down

0 comments on commit f4d4773

Please sign in to comment.