some
is only working for one object although input1 and 2 can have 500 object. If I put logic inside some()
method it's working fine.
How to call method asynchronously inside some
. filterRecord
method has some logic which is re-usable that's why I want to have this inside separate method . Does some()
not work with async await?
const filter1 = [{
"filter1Key": "age",
"filter2Key": "score"
}];
const filter2 = [{
"filter1Key": "name",
"filter2Key": "address.city"
}];
const test1 = input1.forEach((data) => input2.some(async(obj) => {
// filter logic is inside filterRecord method
const output = await filterRecord();
}));
async filterRecord() {
}
<script>
const input1 = [{
'name': "name1",
'email': "email1@email.com",
'age': 10,
'score': 95,
'address': {
'city': "city1"
}
},
{
'name': "name2",
'email': "email2@email.com",
'age': 10,
'score': 45,
'address': {
'city': "city2"
}
},
{
'name': "name3",
'email': "email3@email.com",
'age': 20,
'score': 65,
'address': {
'city': "city3"
}
}
];
// Second Array
const input2 = [{
'id': 1,
'fullname': "name1",
'emailaddress': "email1@email.com",
'age': 10,
'score': 45,
'address': {
'city': "city1"
}
},
{
'id': 5,
'name': "name2",
'email': "email2@email.com",
'age': 20,
'score': 55,
'address': {
'city': "city2"
}
},
{
'name': "name31",
'email': "email3@email.com",
'age': 20,
'score': 65,
'address': {
'city': "city3"
}
}
];
</script>