While going through an array of objects in my Angular component class, I faced a strange issue where the properties kept showing up as undefined
. The function responsible for this behavior looks like this:
upload(): void {
const { fileHandles, relatedThroughID }: { fileHandles: IFileHandle[], relatedThroughID: Guid } = this.form.value;
const postData: IUploadPost = {
base64Files: fileHandles.map(fileHandle => ({ data: fileHandle.base64, extension: fileHandle.extension })),
relatedThroughID: relatedThroughID.toString(),
};
}
I was so taken aback by the output displayed while logging results that I had to capture a screenshot - and indeed, the values in the second log statement turned out to be undefined.
https://i.sstatic.net/Uj5fF.png
To add to the confusion, even accessing items by their index revealed properties marked as undefined
. This peculiar scenario has left me puzzled and unsure how to rectify it. Can anyone shed light on what might be causing this issue? It's certainly a first for me.