I am having a response of all the job orders.
{
"jobOrders": [{
"id": "5b4f7ad860dfee3b009d7452",
"haulier": {
"companyName": "BigDataMatica",
"email": "[email protected]",
"registrationNumber": "nirmal89HJ",
"companyAddress": "RSPURAM",
"companyPhone": "8687678",
"yardAddress": "Pragatinagar",
"yardPhone": "69876876",
"haulierCode": "Haulier",
"billingAddress": "Pragatinagar"
}
},
{
"id": "5b501f8f60dfee3b009d7454",
"haulier": {
"companyName": "BigDataMatica",
"email": "[email protected]",
"registrationNumber": "nirmal89HJ",
"companyAddress": "RS PURAM",
"companyPhone": "8687678",
"yardAddress": "Pragatinagar",
"yardPhone": "69876876",
"haulierCode": "Haulier",
"billingAddress": "Pragatinagar"
}
},
{
"id": "5b5020f360dfee3b009d7455",
"haulier": {
"companyName": "BigDataMatica",
"email": "[email protected]",
"registrationNumber": "nirmal89HJ",
"companyAddress": "RS PURAM",
"companyPhone": "8687678",
"yardAddress": "Pragatinagar",
"yardPhone": "69876876",
"haulierCode": "Haulier",
"billingAddress": "Pragatinagar"
}
}
]
}
Based on the job orders, I need to filter the job orders based on haulier object email key.
let haulierjobordersnames = joborderlist && joborderlist.map && joborderlist.map(a => a.haulier.email);
console.log("haulierjobordersnames", haulierjobordersnames);
output:
["[email protected]", "[email protected]", "[email protected]"]
let haulierjoborders = joborderlist && joborderlist.map && joborderlist.map((el)=>{el.haulier.email == haulierjobordersnames})
console.log("haulierjoborders", haulierjoborders);
output:
[undefined, undefined, undefined]