/
votter
/
NicheAI
Обзор
Документация
Войти
/
votter
/
NicheAI
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
web/js/api.js
44 строки
1 KB
vooterr
Configure GitVerse Pages deployment
21 июл 2026, 22:54
21 июл 2026, 22:54
34b084d
Код
Авторство
О чём код?
// GitVerse Pages publishes only static files. For a full deployment set // window.NICHEAI_API_URL before this script is loaded, for example to // "https://api.example.ru". Docker/Nginx deployments use the same-origin proxy. const API_URL = window.NICHEAI_API_URL || "/api"; window.NicheAPI = { async verify(file) { const form = new FormData(); form.append("file", file); const response = await fetch(`${API_URL}/verify`, { method: "POST", body: form }); if (!response.ok) throw new Error("Ошибка API"); return await response.json(); }, async exportDocx(data, selection) { const response = await fetch(`${API_URL}/export/docx`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ data, selection: selection ? [...selection] : [] }), }); if (!response.ok) throw new Error("Ошибка API"); const blob = await response.blob(); const cd = response.headers.get("Content-Disposition") || ""; const match = cd.match(/filename\*=UTF-8''([^;]+)/); const filename = match ? decodeURIComponent(match[1]) : "nicheai_report.docx"; return { blob, filename }; } };