Untitled
Anis
plain_text
2 years ago
758 B
7
Indexable
import { xoomBackendUrl } from '@/lib/axios/getAxios';
import { useQuery } from 'react-query';
export default function useGetSingleNews(session, id) {
const {
isLoading: singleNewsLoading,
data: singleNews,
refetch: singleNewsRefetch,
} = useQuery(
'admin-single-news',
async () => {
const response = await xoomBackendUrl.get(`/api/admin/news/${id}`, {
headers: { Authorization: `Bearer ${session?.user?.accessToken}` },
});
if (response.status === 200) {
return response.data?.data;
} else {
throw new Error('Failed to fetch all news data!');
}
},
{
cacheTime: 0,
}
);
return { singleNews, singleNewsLoading, singleNewsRefetch };
}Editor is loading...
Leave a Comment