Spaces:
Runtime error

sales / frontend /src /lib /api.ts
Corin1998's picture
Create lib/api.ts
69c142a verified
Raw History Blame Contribute Delete
952 Bytes
export type GenerateReq = {
language: string;
industry: string;
target_company: string;
target_persona: string;
pain_points: string;
value_prop: string;
product_name: string;
cta: string;
tone: string;
variables: Record<string, string>;
length_hint: string;
extra_instr?: string | null;
};
const BASE = import.meta.env.VITE_API_BASE ?? "http://localhost:8000";
export async function generateEmail(payload: GenerateReq) {
const r = await fetch(`${BASE}/generate/email`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload),
});
if (!r.ok) throw new Error(await r.text());
return r.json();
}
export async function lintText(text: string) {
const r = await fetch(`${BASE}/lint`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ text }),
});
if (!r.ok) throw new Error(await r.text());
return r.json();
}