Handle no scheduled alarm case

This commit is contained in:
nemunaire 2022-10-15 14:34:55 +02:00
commit 192e751405
2 changed files with 25 additions and 17 deletions

View file

@ -65,7 +65,11 @@ export async function getAlarmSingle(aid) {
export async function getNextAlarm() {
const res = await fetch(`api/alarms/next`, {headers: {'Accept': 'application/json'}})
if (res.status == 200) {
return new Date(await res.json());
const data = await res.json();
if (data)
return new Date(data);
else
return data;
} else {
throw new Error((await res.json()).errmsg);
}