Skip to content
Snippets Groups Projects
Commit 3f45976b authored by Lukas's avatar Lukas Committed by mcfarhat
Browse files

Create custom hook to fetch post content data

parent b41d4ef3
No related branches found
No related tags found
1 merge request!483Lbudginas/#385 single post page
import { useQuery } from "@tanstack/react-query";
import fetchingService from "@/services/FetchingService";
const usePostContent = (accountName: string, permlink: string) => {
const trimAccount = accountName.replace("@", "");
const { data, isLoading, isError } = useQuery({
queryKey: ["blockSearch", trimAccount, permlink],
queryFn: () => fetchPostContent(trimAccount, permlink),
refetchOnWindowFocus: false,
});
const fetchPostContent = async (accountName: string, permlink: string) => {
if (!accountName || !permlink) return null;
const response = await fetchingService.getContent(accountName, permlink);
return response;
};
return { data, isLoading, isError };
};
export default usePostContent;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment