2025-07-10 21:17:00 +03:00

17 lines
512 B
JavaScript

const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || "http://localhost:8000";
// 📥 הורדת שיר לפי שם
export async function downloadSong(query) {
try {
const res = await fetch(`${API_BASE_URL}/download?query=${encodeURIComponent(query)}`);
if (!res.ok) {
const err = await res.json();
throw new Error(err.detail || "Download failed");
}
return await res.json();
} catch (error) {
console.error("❌ Error downloading song:", error);
throw error;
}
}