tobias 370eac2b25
All checks were successful
continuous-integration/drone/push Build is passing
Save generated payload types in astro types folder
2024-05-20 14:06:01 +02:00

14 lines
432 B
TypeScript

import type { Post } from "@/types/payload-types";
const url = import.meta.env.DEV
? "http://payload:3001"
: `${import.meta.env.PAYLOAD_URL}`;
export const getPosts = async () =>
(await (await fetch(`${url}/api/posts`)).json()).docs as Post[];
export const getPost = async (id: string) =>
(await (await fetch(`${url}/api/posts/${id}`)).json()) as Post;
export const getImageSrc = (src: string) => `${url}/media/${src}`;