uaide-backend / src /utils /api.js
ATS-27's picture
Upload folder using huggingface_hub
af980d7 verified
const API_BASE = import.meta.env.VITE_API_BASE_URL || '';
export async function analyzeMedia(file) {
const formData = new FormData();
formData.append('file', file);
const response = await fetch(`${API_BASE}/api/analyze`, {
method: 'POST',
body: formData,
});
let payload = null;
try {
payload = await response.json();
} catch {
payload = null;
}
if (!response.ok) {
throw new Error(payload?.detail || 'Analysis failed');
}
return payload;
}
export async function checkBackendHealth() {
const response = await fetch(`${API_BASE}/api/health`);
if (!response.ok) {
throw new Error('Backend healthcheck failed');
}
return response.json();
}