// This file contains types and functions related to interacting with the API. export interface NewPost { content: string; token: string; } interface Votes { up: number; down: number; } export interface Post extends NewPost { uuid: string; createdAt: string; votes: Votes; } export async function getPosts(): Promise { // const res = await fetch(`${API_URL}/posts`); const res = await fetch("/api/posts"); const data = await res.json(); return data; } export async function getPost(id: string): Promise { const res = await fetch(`/api/posts/${id}`); const data = await res.json(); return data; } export async function createPost(post: NewPost): Promise { // await fetch(`${API_URL}`, { await fetch("/api/posts", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(post), }); }