Almost there

This commit is contained in:
Daniel Ledda
2020-11-14 16:10:00 +01:00
parent 737fd8411b
commit c54c20ab92
3 changed files with 6 additions and 1 deletions

View File

@@ -47,6 +47,10 @@ class ClimateChart {
private async getInitialDataBlob(): Promise<SnapshotRecords> {
try {
const data = await fetch(this.rootUrl + "/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!");
}
return await data.json();
}
catch (e) {

View File

@@ -12,6 +12,7 @@ function createClimateChart() {
const argsStart = pathname.search(/\?minute-span=/);
if (argsStart !== -1) {
const parsedMins = Number(pathname[12]);
console.log(parsedMins);
if (!isNaN(parsedMins) && parsedMins > 0) {
minutesDisplayed = parsedMins;
}