async function addProfile() { const api = document.getElementById("api").value.trim(); const first = document.getElementById("first").value.trim(); const last = document.getElementById("last").value.trim(); const bio = document.getElementById("bio").value.trim(); const status = document.getElementById("status"); if (!api || !first) { status.textContent = "Укажи адрес Worker и имя"; return; } try { const response = await fetch(api + "/profiles", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ first_name: first, last_name: last, bio: bio }) }); if (!response.ok) { throw new Error("Ошибка API: " + response.status); } status.textContent = "Профиль сохранён!"; await loadProfiles(); } catch (error) { status.textContent = "Ошибка: " + error.message; } }