mirror of
https://github.com/jorisbertomeu/web-screensaver.git
synced 2026-04-19 16:27:40 +02:00
Catch error on HA Collection retrieve
This commit is contained in:
@@ -18,15 +18,19 @@ export class PhotoController {
|
|||||||
let collections = settings.unsplash?.HACollectionsId;
|
let collections = settings.unsplash?.HACollectionsId;
|
||||||
|
|
||||||
if (collections && collections.length > 0) {
|
if (collections && collections.length > 0) {
|
||||||
const resp = await fetch(`${settings.hass.endpoint}/api/states/${collections}`, {
|
try {
|
||||||
headers: {
|
const resp = await fetch(`${settings.hass.endpoint}/api/states/${collections}`, {
|
||||||
Authorization: `Bearer ${settings.hass.token}`
|
headers: {
|
||||||
|
Authorization: `Bearer ${settings.hass.token}`
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const data = await resp?.json();
|
||||||
|
collections = data.state;
|
||||||
|
if (collections.includes(',')) {
|
||||||
|
collections = collections.split(',');
|
||||||
}
|
}
|
||||||
});
|
} catch(e) {
|
||||||
const data = await resp?.json();
|
collections = settings.unsplash.collectionsId;
|
||||||
collections = data.state;
|
|
||||||
if (collections.includes(',')) {
|
|
||||||
collections = collections.split(',');
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
collections = settings.unsplash.collectionsId;
|
collections = settings.unsplash.collectionsId;
|
||||||
|
|||||||
Reference in New Issue
Block a user