From a9d3873579000193c4118323c0e5654b5f9ae201 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Fri, 19 May 2023 12:43:24 -0700 Subject: [PATCH] QNAP widget make sure re-auth status = 200 --- src/widgets/qnap/proxy.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/widgets/qnap/proxy.js b/src/widgets/qnap/proxy.js index 489f24ac..a4d7376d 100644 --- a/src/widgets/qnap/proxy.js +++ b/src/widgets/qnap/proxy.js @@ -64,6 +64,12 @@ async function apiCall(widget, endpoint, service) { key = await login(widget, service); apiUrl = new URL(formatApiCall(`${endpoint}&sid=${key}`, widget)); [status, contentType, data, responseHeaders] = await httpProxy(apiUrl); + + if (status !== 200) { + logger.error("Error getting data from QNAP: %s status %d. Data: %s", apiUrl, status, data); + return { status, contentType, data: null, responseHeaders }; + } + dataDecoded = JSON.parse(xml2json(data.toString(), { compact: true }).toString()); }