diff options
Diffstat (limited to 'src/connector.js')
| -rw-r--r-- | src/connector.js | 23 |
1 files changed, 13 insertions, 10 deletions
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}` } |
