class APIConnector { constructor(url) { this.url = url ?? "" } #fetch(endpoint) { return fetch(this.url + "/api" + endpoint) } fetch(endpoint) { return this.#fetch(endpoint) .then(response => { if (!response.ok) throw new Error(`HTTP error! Status: ${response.status}`) return response.json() }) .then(data => { return data }) .catch(error => { console.error("Fetch error:", error) }) } seek(increment) { return this.fetch(`/seek?increment=${increment}`) } fetchAlbums() { return this.fetch("/albums/get") } albumThumbSrc(key) { return `${this.url}/api/albums/thumb/${key}` } } const apiConnector = new APIConnector("http://localhost:5000") export default apiConnector