From 474a8d0a3b737a2bd225d567b4cfa67fa277f4ce Mon Sep 17 00:00:00 2001 From: Ayush Tiwari Date: Tue, 6 Aug 2024 00:18:05 +0530 Subject: [PATCH] fix hook --- src/services/community-timeline.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/services/community-timeline.ts b/src/services/community-timeline.ts index ab00a53..6b0a869 100644 --- a/src/services/community-timeline.ts +++ b/src/services/community-timeline.ts @@ -120,17 +120,17 @@ export const useUpdateUserPost = () => { export function useGetUserPosts() { const [cookieValue] = useCookie('uni_user_token') - const { isLoading, data, error } = useQuery({ + const state = useQuery({ queryKey: ['userPosts'], queryFn: () => getAllUserPosts(cookieValue), }) let errorMessage = null - if (axios.isAxiosError(error) && error.response) { - errorMessage = error.response.data + if (axios.isAxiosError(state.error) && state.error.response) { + errorMessage = state.error.response.data } - return { isLoading, data, error: errorMessage } + return { ...state, error: errorMessage } } export const useCreateUserPost = () => { @@ -152,17 +152,17 @@ export const useCreateUserPost = () => { export function useGetTimelinePosts() { const [cookieValue] = useCookie('uni_user_token') - const { isLoading, data, error } = useQuery({ + const state = useQuery({ queryKey: ['timelinePosts'], queryFn: () => getAllTimelinePosts(cookieValue), }) let errorMessage = null - if (axios.isAxiosError(error) && error.response) { - errorMessage = error.response.data + if (axios.isAxiosError(state.error) && state.error.response) { + errorMessage = state.error.response.data } - return { isLoading, data, error: errorMessage } + return { ...state, error: errorMessage } } export const useLikeUnlikeTimelinePost = () => {