From e943375d74ce8d48b8ad40b1a5d05437ca4f5c7f Mon Sep 17 00:00:00 2001 From: Tim Keller Date: Mon, 5 May 2025 20:38:42 -0500 Subject: add immich api class and page class --- src/immich.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/immich.js (limited to 'src/immich.js') diff --git a/src/immich.js b/src/immich.js new file mode 100644 index 0000000..d911007 --- /dev/null +++ b/src/immich.js @@ -0,0 +1,28 @@ +export default class ImmichConnector { + constructor(url, apiKey) { + this.url = url + this.apiKey = apiKey + } + + fetchAlbums() { + return this.fetch("/albums") + } + + fetch(endpoint) { + return fetch(this.url + "/api" + endpoint, { + headers: { "x-api-key": this.apiKey } + }) + .then(response => { + if (!response.ok) { + throw new Error(`HTTP error! Status: ${response.status}`) + } + return response.json() + }) + .then(data => { + console.log('Fetched data:', data) + }) + .catch(error => { + console.error('Fetch error:', error) + }) + } +} -- cgit v1.2.3