Files
fast_api_livetse/frontend/assets/js/api.js

20 lines
630 B
JavaScript

const BASE = 'http://127.0.0.1:8000';
export const getItems = () =>
fetch(`${BASE}/user/items`).then(r => r.json());
export const spinWheel = () =>
fetch(`${BASE}/user/spin`, { method: 'POST' }).then(r => r.json());
export const adminGetItems = () =>
fetch(`${BASE}/admin/items`).then(r => r.json());
export const createItem = (title) =>
fetch(`${BASE}/admin/items`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ title })
}).then(r => r.json());
export const deleteItem = (id) =>
fetch(`${BASE}/admin/items/${id}`, { method: 'DELETE' }).then(r => r.json());