Fix: Null-safe access to rightType.title in menu endpoint
- Verwende Optional Chaining (?.) für ur.rightType.title - Filtere null/undefined Werte aus rights Array - Behebt: Cannot read properties of null (reading 'title')
This commit is contained in:
@@ -359,7 +359,7 @@ class NavigationController {
|
||||
});
|
||||
const birthDate = userBirthdateParams.length > 0 ? userBirthdateParams[0].value : (new Date()).toDateString();
|
||||
const age = this.calculateAge(birthDate);
|
||||
const rights = userRights.map(ur => ur.rightType.title);
|
||||
const rights = userRights.map(ur => ur.rightType?.title).filter(Boolean);
|
||||
const filteredMenu = await this.filterMenu(menuStructure, rights, age, user.id);
|
||||
res.status(200).json(filteredMenu);
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user