From 85802c68db1b85dfccce0f3db762e2d54689ccb7 Mon Sep 17 00:00:00 2001 From: 0x1d Date: Sun, 19 Oct 2025 22:42:39 +0200 Subject: [PATCH] fix: configureNodeWiFi method to properly check the response structure --- public/scripts/components/WiFiConfigComponent.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/public/scripts/components/WiFiConfigComponent.js b/public/scripts/components/WiFiConfigComponent.js index 468b991..79050b0 100644 --- a/public/scripts/components/WiFiConfigComponent.js +++ b/public/scripts/components/WiFiConfigComponent.js @@ -285,7 +285,7 @@ class WiFiConfigComponent extends Component { async configureNodeWiFi(node, ssid, password) { logger.debug('WiFiConfigComponent: Configuring WiFi for node:', node.ip); - + const response = await window.apiClient.callEndpoint({ ip: node.ip, method: 'POST', @@ -295,11 +295,13 @@ class WiFiConfigComponent extends Component { { name: 'password', value: password, location: 'body' } ] }); - - if (!response.success) { - throw new Error(response.error || 'Failed to configure WiFi'); + + // Check if the API call was successful based on the response structure + if (!response || response.status !== 200) { + const errorMessage = response?.data?.message || response?.error || 'Failed to configure WiFi'; + throw new Error(errorMessage); } - + return response; }