I am trying to go through my JSON object and add specific fields to their own array.
I am trying to iterate through the below object and store the 'appSupportedId' in its own array.
I am getting an ERROR
ERROR
core.js:15714 ERROR TypeError: info.flatMap is not a function
I have implemented something similar in my code but the only difference with the backend json object is that this below object has a nested array
Any help would be appreciated!
component.ts
userAppDetails:[];
this.incidentService.get(this.id)
.subscribe((info) =>
this.userAppDetails = (info.flatMap(x => x.applicationsSupported)).contactAll().map(y=> y.appSupportedId))
JSON OBJECT
"incidentNumber": 18817,
"Email": null,
"applicationsSupported": [
{
"appSupportedId": 18569,
"supportAreaId": 122,
"supportAreas": {
"applicationId": 122,
"activeFlag": "Y",
},
"appSupportedName": "app 1"
},
{
"appSupportedId": 18592,
"supportAreaId": 123,
"supportAreas": {
"applicationId": 123,
"activeFlag": "Y",
},
"appSupportedName": "app 2"
},
{
"appSupportedId": 18655,
"supportAreaId": 122,
"supportAreas": {
"applicationId": 122,
"activeFlag": "Y",
},
"appSupportedName": "app 3"
}
],
"createdDate": "2020-01-17T18:02:51.000+0000",