diff options
Diffstat (limited to 'src/immich.js')
| -rw-r--r-- | src/immich.js | 28 |
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) + }) + } +} |
