2025-06-04 00:36:06 +03:00

23 lines
714 B
JavaScript

export async function fetchSections() {
const res = await fetch('/apps');
if (!res.ok) throw new Error('Failed to fetch sections');
return res.json();
}
export async function addAppToSection({ section, app }) {
const res = await fetch('/add_app', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ section, app })
});
if (!res.ok) throw new Error(await res.text());
return res.json();
}
export async function getIconUrl(filename) {
const res = await fetch(`/icon/${filename}`);
if (!res.ok) throw new Error(`Failed to fetch icon for ${filename}`);
const data = await res.json();
return data.url; // ✅ must return the actual URL string
}