EventDeck is constantly throwing errors
johnytiago opened this issue · comments
JT commented
EventDeck is constantly throwing this error:
Debug: hapi, internal, implementation, error
TypeError: Uncaught error: Cannot read property 'advertisementLvl' of undefined
at renderObject (/home/production/eventdeck/server/views/company.js:32:129)
at render (/home/production/eventdeck/server/views/company.js:15:10)
at exports.get.handler (/home/production/eventdeck/server/routes/companies/handlers.js:99:11)
at Object.internals.handler (/home/production/eventdeck/node_modules/hapi/lib/handler.js:91:27)
...
The problem comes from here at server/views/company.js
:
advertisementLvl: model.participations.filter(function (p) { return p.advertisementLvl && p.status === PUBLIC_STATUS })[0].advertisementLvl¬
If there is no participation
that passes the filter the array will be empty and therefore the error.