Untitled
unknown
plain_text
2 years ago
767 B
23
Indexable
`/*above this, is writen standard code for apollo configuration client */
export const useBlogPostsHomeData = () => {
const [posts, setPosts] = useState([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
const fetchPostsData = async () => {
const query = gql`
query Posts {
posts(first: 3) {
nodes {
author {
}
}
}
`;
try {
const result = await fetchData(query);
setPosts(result.posts.nodes);
setLoading(false);
} catch (error) {
setError(error);
setLoading(false);
}
};
useEffect(() => {
fetchPostsData();
});
return { posts, loading, error, posts };
};Editor is loading...
Leave a Comment