]> ToastFreeware Gitweb - chrisu/seepark.git/blobdiff - web/static/seepark_web.js
don't ignore errors from fetch().then()
[chrisu/seepark.git] / web / static / seepark_web.js
index ff430ff9337969d9775bd8da1022c8305aca1fef..5baed88ef6574727e0c28753ef4bfb34fd6cc494 100644 (file)
@@ -160,24 +160,9 @@ function dayschart(element, title, days, xtickformat) {
        });
 
        // reload data in charts
-       // TODO: this is basically the same as the unused loaddays function below
        setInterval(
                function() {
-                       if (element.substr(0, 7) == 'chart_w') {
-                               console.log("water");
-                               chart.load({
-                                       url: api_base_url_sensors + beginend(days),
-                                       mimeType: 'json'
-                               });
-                               chart.flush();
-                       } else {
-                               console.log("air");
-                               chart.load({
-                                       url: api_base_url_weather + beginend(days),
-                                       mimeType: 'json'
-                               });
-                               chart.flush();
-                       }
+                       loaddays(chart, element, days);
                },
                refresh_interval
        );
@@ -238,7 +223,7 @@ setInterval(
                                airtime.innerText  = strftime('%Y-%m-%d H:%M', data['timestamp']);
                        })
                        .catch(function(error) {
-                               // handle error
+                               console.log(error);
                        });
                fetch(api_url_currentwater)
                        .then((resp) => resp.json())
@@ -247,7 +232,7 @@ setInterval(
                                watertime.innerText  = strftime('%Y-%m-%d H:%M', data['timestamp']);
                        })
                        .catch(function(error) {
-                               // handle error
+                               console.log(error);
                        });
        },
        refresh_interval