Almost there

This commit is contained in:
Daniel Ledda
2020-11-14 15:25:04 +01:00
parent 1a1dd81407
commit 30e9840749

View File

@@ -45,7 +45,7 @@ class ClimateChart {
}
private async getInitialDataBlob(): Promise<SnapshotRecords> {
const data = await fetch(this.rootUrl + "/data?since=" + new Date((new Date().getTime() - this.minutesDisplayed * 60 * 1000)).toISOString());
const data = await fetch("data?since=" + new Date((new Date().getTime() - this.minutesDisplayed * 60 * 1000)).toISOString());
const payload = await data.json();
if (payload.snapshots.length < 0) {
throw new Error("Bad response - no snapshots found!");
@@ -90,7 +90,7 @@ class ClimateChart {
private async updateFromServer() {
const currentTime = (new Date(this.latestSnapshot.time)).toISOString();
const url = "/" + this.rootUrl + "data?since=" + currentTime;
const url = "data?since=" + currentTime;
try {
const payload: SnapshotRecords = await (await fetch(url)).json();
if (payload.snapshots.length > 0 && new Date(payload.snapshots[0].time).getTime() > Date.now()) {