This is an automated email from the ASF dual-hosted git repository. robin0716 pushed a commit to branch robin/test in repository https://gitbox.apache.org/repos/asf/incubator-answer.git
commit 67685533d8a15780ddd1614a2bb1137ea5680ab4 Author: shuai <[email protected]> AuthorDate: Wed Sep 25 11:12:20 2024 +0800 fix: badges allow 404 --- ui/src/services/client/badges.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ui/src/services/client/badges.ts b/ui/src/services/client/badges.ts index 7f3f8abd..e1617aab 100644 --- a/ui/src/services/client/badges.ts +++ b/ui/src/services/client/badges.ts @@ -40,7 +40,10 @@ export const useGetAllBadges = () => { export const useGetBadgeInfo = (id: string) => { const { data, error, mutate } = useSWR<Type.BadgeInfo, Error>( `/answer/api/v1/badge?id=${id}`, - request.instance.get, + (url) => + request.get(url, { + allow404: true, + }), ); return { data, @@ -51,12 +54,17 @@ export const useGetBadgeInfo = (id: string) => { }; export const useBadgeDetailList = (params: Type.BadgeDetailListReq) => { + if (!params.badge_id) return { data: null, isLoading: false, error: null }; const { data, error, mutate } = useSWR<Type.BadgeDetailListRes, Error>( `/answer/api/v1/badge/awards/page?${qs.stringify(params, { skipNulls: true, })}`, - request.instance.get, + (url) => + request.get(url, { + allow404: true, + }), ); + return { data, isLoading: !data && !error,
