ctucx.git: mqtt-webui

webui for mqtt, can be used to control/display data in mqtt-topics

commit 7bd517d5ac10b5cbbb9725289139c63a066a3c60
parent 7ef67e5b910e7dc3dd5f56d5d63b63973695fa61
Author: Leah (ctucx) <git@ctu.cx>
Date: Mon, 12 Dec 2022 19:47:50 +0100

webui.js: don't crash if message isn't json
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/webui.js b/src/webui.js
@@ -40,7 +40,9 @@ const transformMessage = (input, meta) => {
 }
 
 const onMessage = (topic, message) => {
-	message = JSON.parse(message.toString());
+	try {
+		message = JSON.parse(message.toString());
+	} catch(e) { }
 
 	document.querySelectorAll('[data-mqtt-topic="' + topic + '"]').forEach((element) => {
 		let value = null;