Skip to content

Commit

Permalink
[FE] fix: 베스트리뷰 요청 204 처리 (#742)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leejin-Yang authored Oct 12, 2023
1 parent 22e792d commit 9f3232c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ interface BestReviewItemProps {

const BestReviewItem = ({ productId }: BestReviewItemProps) => {
const { data: bestReview } = useBestReviewQuery(productId);

if (!bestReview) {
return null;
}

const { profileImage, userName, rating, favoriteCount, content } = bestReview;

const theme = useTheme();
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/hooks/queries/rank/useBestReviewQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import type { Review } from '@/types/review';

const fetchBestReview = async (productId: number) => {
const response = await rankApi.get({ params: `/products/${productId}/reviews` });

if (response.status === 204) {
return null;
}

const data: Review = await response.json();
return data;
};
Expand Down

0 comments on commit 9f3232c

Please sign in to comment.