18 lines
393 B
TypeScript
18 lines
393 B
TypeScript
import {GET_POSTS} from "@graphql/queries/standalone/blog";
|
|
import type {IPostResponse} from '@types';
|
|
|
|
export function usePosts() {
|
|
const { data, error } = useAsyncQuery<IPostResponse>(GET_POSTS);
|
|
|
|
const posts = computed(() => data.value?.posts.edges ?? []);
|
|
|
|
watch(error, (err) => {
|
|
if (err) {
|
|
console.error('usePosts error:', err);
|
|
}
|
|
});
|
|
|
|
return {
|
|
posts,
|
|
};
|
|
}
|