Encountering an issue with a JavaScript object retrieved from a MongoDB: when logging the parent object, the child object is visible. However, attempting to access or log the child object results in undefined.
const templateResponse = await this.dbService.findbyCode(req); // <= here I get the parent object
console.log('EmailService -> getEmailCOntent -> templateResponse', templateResponse);
if (templateResponse) {
console.log('EmailService -> getEmailCOntent -> templateResponse6666', templateResponse.email);
}
EmailService -> sendMails -> emailContent
When logging the parent object, the child email object is visible:
{ _id: 5f5421eaa9248b90c815d80b,
email:
{ to: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="73161e121a1f331e121a1f5d101c1e">[email protected]</a>',
cc: '',
bcc: '',
subject: 'testttt',
body: 'this is a test',
from: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6e0001431c0b1e02172e1a0b1d1a400d0103">[email protected]</a>' },
code: 'REQUESTOREMAILNOACCESS',
name: '',
description: '',
__v: 0
}
Attempting to log the child object results in undefined, even when using templateResponse['email']
EmailService -> getEmailCOntent -> templateResponse.email
undefined