2025-08-03 18:50:28 +03:00

16 lines
559 B
JavaScript

const BASE_URL = import.meta.env.VITE_API_URL || "http://localhost:8000";
export async function downloadSong(query) {
const response = await fetch(`${BASE_URL}/download?query=${encodeURIComponent(query)}`);
if (!response.ok) {
const error = await response.json();
throw new Error(error.detail || "Unknown error");
}
return await response.json();
}
export async function getDownloadedSongs() {
const response = await fetch(`${BASE_URL}/songs`);
if (!response.ok) throw new Error("Failed to fetch songs");
return await response.json();
}