Skip to content

Commit

Permalink
Fix: fritzbox error when response contains empty values (#2463)
Browse files Browse the repository at this point in the history
  • Loading branch information
evorg authored Dec 10, 2023
1 parent bccd73f commit d38b313
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/widgets/fritzbox/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ async function requestEndpoint(apiBaseUrl, service, action) {
const response = {};
try {
const jsonData = JSON.parse(xml2json(data));
const responseElements = jsonData?.elements[0]?.elements[0]?.elements[0]?.elements || [];
const responseElements = jsonData?.elements?.[0]?.elements?.[0]?.elements?.[0]?.elements || [];
responseElements.forEach((element) => {
response[element.name] = element.elements[0]?.text || "";
response[element.name] = element.elements?.[0].text || "";
});
} catch (e) {
logger.debug(`Failed parsing ${service}->${action} response:`, data);
Expand Down

0 comments on commit d38b313

Please sign in to comment.