From 01482068726ee6de5336ed01bfadaeaaaf02666e Mon Sep 17 00:00:00 2001 From: Tim Keller Date: Tue, 17 Jun 2025 22:33:24 -0500 Subject: settings page save/load config --- src/connector.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src/connector.js') diff --git a/src/connector.js b/src/connector.js index 97071c6..29f0cff 100644 --- a/src/connector.js +++ b/src/connector.js @@ -19,12 +19,8 @@ class APIConnector { }) } - #fetch(endpoint) { - return fetch(this.url + "/api" + endpoint) - } - - fetch(endpoint) { - return this.#fetch(endpoint) + fetch(endpoint, c) { + return fetch(this.url + "/api" + endpoint, c ?? {}) .then(response => { if (!response.ok) throw new Error(`HTTP error! Status: ${response.status}`) @@ -38,14 +34,21 @@ class APIConnector { }) } + post(endpoint, body) { + return this.fetch(endpoint, { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify(body), + }) + } + seek(increment) { - //return this.fetch(`/seek?increment=${increment}`) this.socket.emit("seek", increment) } - fetchAlbums() { - return this.fetch("/albums") - } + fetchAlbums() { return this.fetch("/albums") } + fetchConfig() { return this.fetch("/config") } + updateConfig(config) { return this.post("/config/update", config) } albumSrc(key) { return `${this.url}/api/redirect/albums/${key}` } assetSrc(key) { return `${this.url}/api/asset/${key}` } -- cgit v1.2.3