Working on next alarm retrieval
This commit is contained in:
parent
6e54ad1a87
commit
9a06d04ce0
8 changed files with 261 additions and 40 deletions
|
|
@ -61,3 +61,28 @@ export async function getAlarmSingle(aid) {
|
|||
throw new Error((await res.json()).errmsg);
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
} else {
|
||||
throw new Error((await res.json()).errmsg);
|
||||
}
|
||||
}
|
||||
|
||||
export async function newNCyclesAlarm(nCycles) {
|
||||
const res = await fetch('api/alarms/single', {
|
||||
method: 'POST',
|
||||
headers: {'Accept': 'application/json'},
|
||||
body: JSON.stringify({
|
||||
time: new Date(Date.now() + 600000 + 5400000 * nCycles)
|
||||
}),
|
||||
});
|
||||
if (res.status == 200) {
|
||||
const data = await res.json();
|
||||
return new AlarmSingle(data);
|
||||
} else {
|
||||
throw new Error((await res.json()).errmsg);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue