summaryrefslogtreecommitdiff
path: root/src/immich.js
diff options
context:
space:
mode:
authorTim Keller <tjk@tjkeller.xyz>2025-05-05 20:38:42 -0500
committerTim Keller <tjk@tjkeller.xyz>2025-05-05 20:38:42 -0500
commite943375d74ce8d48b8ad40b1a5d05437ca4f5c7f (patch)
tree36921b2275b14e295e0250ab9509c23c67e5487b /src/immich.js
parenta3651595531e210916b29f66ac7cce61d5d87670 (diff)
downloadimmich-frame-e943375d74ce8d48b8ad40b1a5d05437ca4f5c7f.tar.xz
immich-frame-e943375d74ce8d48b8ad40b1a5d05437ca4f5c7f.zip
add immich api class and page class
Diffstat (limited to 'src/immich.js')
-rw-r--r--src/immich.js28
1 files changed, 28 insertions, 0 deletions
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)
+ })
+ }
+}