I have the following data
[
{
"itemType": "HEADER",
"createdBy": "Jake",
"deliveredBy": "Paul",
},
{
"itemType": "HEADER_DATA",
"createdBy": "Ryan",
"deliveredBy": "Blair",
},
{
"itemType": "HEADER_DATA",
"createdBy": "John",
"deliveredBy": "Doe",
},
{
"itemType": "HEADER_DATA",
"createdBy": "Sally",
"deliveredBy": "Hansen",
}
]
I want to separate out the items by the item type
test(itemType: string) {
this.service
.getData(itemType)
.pipe()
.subscribe(([{itemType, createdBy, deliveredBy}]) => {
if (itemType === 'HEADER') {
console.log('1');
}
else if (itemType === 'HEADER_DATA') {
console.log('2');
}
});
}
The console never reaches 2. I know this is a simple logic issue but I have been at it for a while and cannot seem to figure it out.
Thank you for your time and help
Stackblitz here