Fix: fritzbox error when response contains empty values (#2463)

pull/2468/head
Thorben 5 months ago committed by GitHub
parent bccd73fe2d
commit d38b313177
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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);

Loading…
Cancel
Save