const API_URL = "/api/v1" export async function get( url: string, cache?: "no-store" | "force-cache", revalidate?: number ): Promise { const token = localStorage.getItem("ephemrToken") return ( await fetch(API_URL + url, { method: "GET", //cache: cache ?? "no-store", headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json", }, next: { revalidate: revalidate ?? 0 }, }) ).json() as Res } export async function post( url: string, body: any, cache?: "no-store" | "force-cache", revalidate?: number ): Promise { const token = localStorage.getItem("ephemrToken") return ( await fetch(API_URL + url, { method: "POST", //cache: cache ?? "no-store", headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json", }, body: JSON.stringify(body), next: { revalidate: revalidate ?? 0 }, }) ).json() as Res } export async function patch( url: string, body: any, cache?: "no-store" | "force-cache", revalidate?: number ): Promise { const token = localStorage.getItem("ephemrToken") return ( await fetch(API_URL + url, { method: "PATCH", //cache: cache ?? "no-store", headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json", }, body: JSON.stringify(body), next: { revalidate: revalidate ?? 0 }, }) ).json() as Res } export async function requestDelete( url: string, body: any, cache?: "no-store" | "force-cache", revalidate?: number ): Promise { const token = localStorage.getItem("ephemrToken") return ( await fetch(API_URL + url, { method: "DELETE", //cache: cache ?? "no-store", headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json", }, body: JSON.stringify(body), next: { revalidate: revalidate ?? 0 }, }) ).json() as Res }