我有这个大型的计算属性,用于监听对象的变化。它基本上被用作 POST 请求的有效负载(这在这里无关紧要,但只是上下文的仅供参考)。
问题是,我收到了这个错误,这不会破坏任何东西,但可能应该在我们推进分期之前解决。
我正在处理完全加载的数据,所以我不明白其中的 undefined
部分。一切都应该准备好了。谁能看到我没看到的东西?
我已经用可选的链接来填充对象(我不太明白,只知道它会使错误消失:D)并且这也没有帮助。
objForApi() {
const event = this.eventData?.event?.data;
return {
event: {
eventName: event.name,
eventStatusID: event.event_status?.id,
is_scheduled: event.is_scheduled || false,
eventTypeID: event.event_type?.id,
severityID: event.severity?.id,
businessImpactID: event.business_impact?.id,
/* Does not appear, to investigate */
/* primaryContactID: this.eventData.event.data.primaryContact.id, */
/* startDate: event.local_start_date, */
startDate: event.local_start_date,
/* startTime: event.local_start_time, */
startTime: '08:02:00',
/* endDate: event.local_end_date, */
endDate: '',
/* endTime: event.local_end_time, */
endTime: '',
primaryContactID: null,
description: event.description,
businessImpactDescription:
event.business_impact_description,
links: event.links,
eventScopes: [
/* application instance studies */
...event.scopes?.appInstances
?.map((instance) => {
return [
!window._.isEmpty(instance.businessImpact)
? {
appInstanceID: instance.id,
businessImpactID:
instance?.businessImpact?.id,
}
: undefined,
...instance.studies_impacted?.map(
(study) => {
return [
!window._.isEmpty(
study.businessImpact
)
? {
appInstanceID:
instance.id,
studyID: study.id,
businessImpactID:
study
?.businessImpact
?.id,
}
: undefined,
...study.capabilities_impacted?.map(
(capability) => ({
appInstanceID:
instance.id,
studyID: study.id,
businessImpactID:
capability
.businessImpact
.id,
capabilityID:
capability.id,
})
),
];
}
),
].flat();
})
.flat(),
...event.scopes?.studies
?.map((study) => {
return [
!window._.isEmpty(study.businessImpact)
? {
appInstanceID: null,
studyID: study.id,
businessImpactID:
study?.businessImpact?.id,
}
: undefined,
...study.capabilities_impacted?.map(
(capability) => ({
appInstanceID: null,
studyID: study?.id,
businessImpactID:
capability.businessImpact?.id,
capabilityID: capability?.id,
})
),
].flat();
})
.flat(),
].filter((item) => item),
},
};
},