🐛 Fix wrong access on properties of widgets and apps in api

This commit is contained in:
Meierschlumpf
2022-12-19 18:17:56 +01:00
parent 383a7fa04b
commit 8fa9cfaccf
7 changed files with 45 additions and 29 deletions

View File

@@ -1,6 +1,7 @@
import axios from 'axios';
import { NextApiRequest, NextApiResponse } from 'next';
import { getConfig } from '../../../../tools/config/getConfig';
import { IDashDotTile } from '../../../../widgets/dashDot/DashDotTile';
async function Get(req: NextApiRequest, res: NextApiResponse) {
const { configName } = req.query;
@@ -13,7 +14,15 @@ async function Get(req: NextApiRequest, res: NextApiResponse) {
const config = getConfig(configName);
const dashDotUrl = config.widgets.dashdot?.properties.url;
const dashDotWidget = config.widgets.find((x) => x.id === 'dashdot');
if (!dashDotWidget) {
return res.status(400).json({
message: 'There is no dashdot widget defined',
});
}
const dashDotUrl = (dashDotWidget as IDashDotTile).properties.url;
if (!dashDotUrl) {
return res.status(400).json({

View File

@@ -1,6 +1,7 @@
import axios from 'axios';
import { NextApiRequest, NextApiResponse } from 'next';
import { getConfig } from '../../../../tools/config/getConfig';
import { IDashDotTile } from '../../../../widgets/dashDot/DashDotTile';
async function Get(req: NextApiRequest, res: NextApiResponse) {
const { configName } = req.query;
@@ -12,8 +13,15 @@ async function Get(req: NextApiRequest, res: NextApiResponse) {
}
const config = getConfig(configName);
const dashDotWidget = config.widgets.find((x) => x.id === 'dashdot');
const dashDotUrl = config.widgets.dashdot?.properties.url;
if (!dashDotWidget) {
return res.status(400).json({
message: 'There is no dashdot widget defined',
});
}
const dashDotUrl = (dashDotWidget as IDashDotTile).properties.url;
if (!dashDotUrl) {
return res.status(400).json({