File size: 546 Bytes
7b007ed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Thin client for the Rune Goblin FastAPI backend.
const BASE = import.meta.env.VITE_API_BASE ?? "";

async function post(path, body) {
  const res = await fetch(`${BASE}${path}`, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: body ? JSON.stringify(body) : undefined,
  });
  if (!res.ok) throw new Error(`${path} -> ${res.status}`);
  return res.json();
}

export const newGame = () => post("/api/new");
export const castSpell = (sessionId, runes) =>
  post("/api/cast", { session_id: sessionId, runes });