Files
TallerCiCd/frontend/src/services/api.js
2025-12-16 09:32:14 +01:00

45 lines
1.2 KiB
JavaScript

/*
CI/CD Workshop
Copyright (C) 2025 OpenBokeron
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { API_BASE } from '../config';
async function getJson(endpoint) {
const response = await fetch(`${API_BASE}${endpoint}`);
if (!response.ok) {
throw new Error('Respuesta no valida del servidor');
}
return response.json();
}
export async function getMenu() {
return getJson('/menu');
}
export async function getPrices() {
const data = await getJson('/prices');
return data.items || [];
}
export async function getCiStatus() {
return getJson('/health');
}
export async function getBuildHistory() {
return getJson('/builds');
}