-
Notifications
You must be signed in to change notification settings - Fork 1
[Feat] 마이페이지 회원이 작성한 리뷰/응원한 스토리 확인 기능 #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e61be20
9ecc3c5
425788f
973f157
2b23ec8
f4836b1
b127f91
d592d2a
bb6aafb
87660b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import api from "@/apis/instance/api"; | ||
|
|
||
| export const getReviews = async () => { | ||
| const res = await api.get("/reviews/get-all-member-reviews"); | ||
| return res.data; | ||
| }; | ||
|
|
||
| export const getCheers = async () => { | ||
| const res = await api.get("/story/member-likes"); | ||
| return res.data; | ||
| }; | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,11 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { useQuery } from "@tanstack/react-query"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { getReviews } from "@/apis/myPage/getDetail"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { getCheers } from "@/apis/myPage/getDetail"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const useGetReviews = () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return useQuery({ queryKey: ["userReview"], queryFn: () => getReviews() }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const useGetCheers = () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return useQuery({ queryKey: ["userCheers"], queryFn: () => getCheers() }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+5
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion React Query 훅 개선 필요 React Query 훅 구현이 기본적인 형태로 되어 있어, 추가적인 옵션 설정이 필요합니다. 다음과 같이 staleTime, cacheTime, 에러 처리 등 개선된 옵션을 추가하는 것이 좋습니다: export const useGetReviews = () => {
- return useQuery({ queryKey: ["userReview"], queryFn: () => getReviews() });
+ return useQuery({
+ queryKey: ["userReview"],
+ queryFn: getReviews,
+ staleTime: 5 * 60 * 1000, // 5분
+ cacheTime: 10 * 60 * 1000, // 10분
+ retry: 1,
+ onError: (error) => {
+ console.error("리뷰 데이터 가져오기 실패:", error);
+ }
+ });
};
export const useGetCheers = () => {
- return useQuery({ queryKey: ["userCheers"], queryFn: () => getCheers() });
+ return useQuery({
+ queryKey: ["userCheers"],
+ queryFn: getCheers,
+ staleTime: 5 * 60 * 1000, // 5분
+ cacheTime: 10 * 60 * 1000, // 10분
+ retry: 1,
+ onError: (error) => {
+ console.error("응원 데이터 가져오기 실패:", error);
+ }
+ });
};이렇게 변경하면 다음과 같은 이점이 있습니다:
📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| import api from "@/apis/instance/api"; | ||
|
|
||
| export const postRecipt = async (formData) => { | ||
| // axios에 formData를 던지면, multipart/form-data; boundary=... 를 자동으로 붙여줍니다. | ||
| const res = await api.post("/naver/receipt", formData); | ||
| return res.data; | ||
| }; |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
API 요청 함수의 오류 처리 개선이 필요합니다.
API 호출 시 오류 처리 로직이 없습니다. API 요청 중 발생할 수 있는 네트워크 오류나 서버 오류에 대한 처리가 필요합니다.
다음과 같이 try-catch 구문을 추가하여 개선할 수 있습니다:
export const getReviews = async () => { + try { const res = await api.get("/reviews/get-all-member-reviews"); return res.data; + } catch (error) { + console.error("리뷰 데이터 가져오기 실패:", error); + throw error; + } }; export const getCheers = async () => { + try { const res = await api.get("/story/member-likes"); return res.data; + } catch (error) { + console.error("응원 데이터 가져오기 실패:", error); + throw error; + } };📝 Committable suggestion
🤖 Prompt for AI Agents