Almost there
This commit is contained in:
@@ -45,7 +45,7 @@ class ClimateChart {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async getInitialDataBlob(): Promise<SnapshotRecords> {
|
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();
|
const payload = await data.json();
|
||||||
if (payload.snapshots.length < 0) {
|
if (payload.snapshots.length < 0) {
|
||||||
throw new Error("Bad response - no snapshots found!");
|
throw new Error("Bad response - no snapshots found!");
|
||||||
@@ -90,7 +90,7 @@ class ClimateChart {
|
|||||||
|
|
||||||
private async updateFromServer() {
|
private async updateFromServer() {
|
||||||
const currentTime = (new Date(this.latestSnapshot.time)).toISOString();
|
const currentTime = (new Date(this.latestSnapshot.time)).toISOString();
|
||||||
const url = "/" + this.rootUrl + "data?since=" + currentTime;
|
const url = "data?since=" + currentTime;
|
||||||
try {
|
try {
|
||||||
const payload: SnapshotRecords = await (await fetch(url)).json();
|
const payload: SnapshotRecords = await (await fetch(url)).json();
|
||||||
if (payload.snapshots.length > 0 && new Date(payload.snapshots[0].time).getTime() > Date.now()) {
|
if (payload.snapshots.length > 0 && new Date(payload.snapshots[0].time).getTime() > Date.now()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user