saaheerpurav's picture
first commit
1bb18a0
Raw
History Blame Contribute Delete
682 Bytes
const BASE = ''; // Same origin — FastAPI serves both API and frontend
export const resetEnv = (task = 'easy') =>
fetch(`${BASE}/reset?task=${task}`).then(r => r.json());
export const stepEnv = (action) =>
fetch(`${BASE}/step`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(action),
}).then(r => {
if (!r.ok) return r.json().then(e => Promise.reject(e));
return r.json();
});
export const getState = () =>
fetch(`${BASE}/state`).then(r => r.json());
export const getGrade = () =>
fetch(`${BASE}/grade`).then(r => r.json());
export const getTasks = () =>
fetch(`${BASE}/tasks`).then(r => r.json());