I have an angular app and in one of the components I'm getting user's notifications(Emails) via a service. the service returns an array of Objects and in each object there's information of an email like subject , userid of the sender, etc. the structure of array of email object is like this:
[{
UserId:"...",
Notification:{
Subject:null,
Body:"<div>...</div>",
.
.
.
},
.
.
.
},
.
.
.]
some emails don't have subject and the value of Subject property is null in the object. I want to set a value for emails with Subject:null.
this.notifService.getAllNotificationsForCurrentUser(userId)
.pipe(
map(emails => {
emails.map(email=>{
if(email.Notification.Subject === null){
email.Notification.Subject = "(No Subject)";
}
})
}
)
.subscribe(
result=> this.messages = result
);
I used map operator and it doesn't work. and it has some errors:
Cannot read property 'Notification' of undefined
how can I fix it?