Receiving of mods may fail, so return then an empty array as fallback

This commit is contained in:
Dennis Heinrich 2024-11-28 09:44:31 +01:00
parent bdb80dbc4e
commit c672838f1d

View file

@ -119,9 +119,13 @@ export default class ServerStatusFeed {
return dayTime / (60 * 60 * 1000) + 0.0001; return dayTime / (60 * 60 * 1000) + 0.0001;
} }
/**
* Get the server mods from the server stats feed
* @returns {IMod[]} The server mods as an array of IMod objects
*/
public getServerMods(): IMod[] { public getServerMods(): IMod[] {
let modList = this.getServerStats()?.Server.Mods.Mod; let modList = this.getServerStats()?.Server?.Mods?.Mod;
if(modList === undefined || !Array.isArray(modList)) { if(modList === undefined || !Array.isArray(modList) || modList == null) {
return []; return [];
} }
return modList.map((mod: any) => { return modList.map((mod: any) => {