blob: d911007ea4290fa868c9326e421abfe517f48d91 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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)
})
}
}
|