I have seller and buyer information inside an array, i need to check if the id matches with either seller or buyer id inside the array, then i need to remove the object from the array.
here is the array:
[
{
"transactionId": null,
"buyer": {
"userId": "eu-central-1",
"email": "pic@gmail.com",
"firstName": "pic",
"lastName": "1",
"_id": "5902ca3ce201550655a7bbf8"
},
"seller": {
"userId": "eu-central-2",
"email": "pic2@gmail.com",
"firstName": "pic",
"lastName": "2",
"_id": "5902ca3ce201550655a7bbf7"
}
}
]
i have the userid eu-central-2. i want the expected output as,
[
{
"transactionId": null,
"user": {
"userId": "eu-central-1",
"email": "pic@gmail.com",
"firstName": "pic",
"lastName": "1",
"_id": "5902ca3ce201550655a7bbf8"
}
}
]
what i tried
let data = results.filter(result=> seller.userId || buyer.userId == userId);
via face turn
No comments:
Post a Comment