@ -1,7 +1,12 @@
|
||||
import type { Post } from "../types";
|
||||
|
||||
const url =
|
||||
process.env.NODE_ENV === "development"
|
||||
? "http://payload:3001"
|
||||
: `https://${process.env.PAYLOAD_URL}`;
|
||||
|
||||
export const getPosts = async () =>
|
||||
(await (await fetch("http://payload:3001/api/posts")).json()).docs as Post[];
|
||||
(await (await fetch(`${url}/api/posts`)).json()).docs as Post[];
|
||||
|
||||
export const getPost = async (id: string) =>
|
||||
(await (await fetch(`http://payload:3001/api/posts/${id}`)).json()) as Post;
|
||||
(await (await fetch(`${url}/api/posts/${id}`)).json()) as Post;
|
||||
|
Reference in New Issue
Block a user