Suppose this is my api response-
I need to assign followUpLists to FollowList array using for loop? how can i code the for loop in typescript?
{
"Info": [
{
"CustomerId": "3",
"CustomerName": "Sreejesh Panayappilly ",
"followUpLists": [
{
"CustomerId": "3",
"CustomerName": "Sreejesh Panayappilly ",
"ProductName": "OLT - GPON - V1600G0 - 4 PON PORT",
"MacId": "14A72BA2AFF2",
"AMCStartDate": "0001-01-01T00:00:00",
"AMCEndDate": "0001-01-01T00:00:00",
"AMCStatus": 1,
"FollowStatus": 0
},
{
"CustomerId": "3",
"CustomerName": "Sreejesh Panayappilly ",
"ProductName": "OLT - GPON - V1600G1 (B) - 8 PON PORT",
"MacId": "14A72BF09C40",
"AMCStartDate": "0001-01-01T00:00:00",
"AMCEndDate": "0001-01-01T00:00:00",
"AMCStatus": 1,
"FollowStatus": 0
}
]
},
{
"CustomerId": "5",
"CustomerName": "Priyamvadan",
"followUpLists": [
{
"CustomerId": "5",
"CustomerName": "Priyamvadan",
"ProductName": "OLT - GPON - V1600G1 (B) - 8 PON PORT",
"MacId": "14A72BF09B8C",
"AMCStartDate": "0001-01-01T00:00:00",
"AMCEndDate": "0001-01-01T00:00:00",
"AMCStatus": 1,
"FollowStatus": 1
}
]
},
],
"Status": true,
"Message": "Data Collected Successfully."
}
I need to assign followUpLists array to FollowList array using for loop? how can i code the for loop in typescript?
CodePudding user response:
Maybe try :
const FollowList = [];
yourObject.Info.map(e => FollowList.push(...e.followUpLists));