From fea7e7e333b47185401582d7c51c6b28cfbf3319 Mon Sep 17 00:00:00 2001 From: Stephan Stricker Date: Wed, 27 Dec 2023 19:43:40 +0100 Subject: [PATCH] Account for different API versions --- README.md | 1 + lib/web_api.js | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3ff40af..f1c388f 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,7 @@ When the adapter crashes or another Code error happens, this error message that ## Changelog ### **WORK IN PROGRESS** - Added new section for WIFI settings. Some settings can be changed via the adapter. +- Account for different API versions ### 0.1.6 (2023-12-26) - Account for different API versions diff --git a/lib/web_api.js b/lib/web_api.js index 8e46904..d134d9b 100644 --- a/lib/web_api.js +++ b/lib/web_api.js @@ -244,7 +244,7 @@ class SrmClient { } /** - * Retrieve knowned devices by router and information like IP, signal, etc... + * Retrieve known devices by router and information like IP, signal, etc... * * @return {Promise} Devices */ @@ -261,7 +261,8 @@ class SrmClient { } catch (error) { if (error.message === 'This API version is not supported') { if (api_version > 1){ - this.getAllDevices(api_version - 1); + const nodes = (await this.getAllDevices(api_version - 1)); + return nodes; } else{ throw new Error('This API version is not supported'); @@ -271,7 +272,6 @@ class SrmClient { throw new Error(error.message); } } - return []; } /** @@ -305,7 +305,8 @@ class SrmClient { } catch (error) { if (error.message === 'This API version is not supported') { if (api_version > 1){ - this.getMeshNodes(api_version - 1); + const nodes = await this.getMeshNodes(api_version - 1); + return nodes; } else{ throw new Error('This API version is not supported'); @@ -315,7 +316,6 @@ class SrmClient { throw new Error(error.message); } } - return []; } /**