I have an array which has a list of values and some of them are promises that needs to be resolved.
allGlobalFilters": [
{
"id": 503,
"pubId": 18,
"type": 15,
"value": "{ \"adsize\": [\"638x335\" , \"400x300\" , \"300x1050\", \"320x100\", \"640x480\" , \"700x392\", \"360x480\", \"896x502\", \"960x538\", \"1024x573\", \"1088x609\"]}",
"status": 4,
"createTs": null,
"updateTs": null,
"createUser": "MMM",
"updateUser": null,
"percentage": 100,
"rtbSspPublishers": { // the promise part
"id": 18,
"name": "Mobile Nations\r\n",
"domain": "http://www.mobilenations.com",
"extPublisherId": 17
}
},
{
"id": 505,
"pubId": 19,
"type": 15,
"value": "{ \"adPlatformType\": [\"APP\"] }",
"status": 4,
"createTs": null,
"updateTs": null,
"createUser": null,
"updateUser": null,
"percentage": 0,
"rtbSspPublishers": { // the promise part
"id": 19,
"name": "Tom's Guide",
"domain": "www.tomsguide.com",
"extPublisherId": 17
}
},
{
"id": 514,
"pubId": 19,
"type": 15,
"value": "{ \"adPlatformType\": [\"WEB\"] }",
"status": 4,
"createTs": null,
"updateTs": null,
"createUser": null,
"updateUser": null,
"percentage": 100,
"rtbSspPublishers": { // the promise part
"id": 19,
"name": "Tom's Guide",
"domain": "www.tomsguide.com",
"extPublisherId": 17
}
},
{
"id": 516,
"pubId": 19,
"type": 15,
"value": "{\"adPlatformType\": [\"MOBILE_WEB\"]}",
"status": 4,
"createTs": null,
"updateTs": null,
"createUser": null,
"updateUser": null,
"percentage": 100,
"rtbSspPublishers": { // the promise part
"id": 19,
"name": "Tom's Guide",
"domain": "www.tomsguide.com",
"extPublisherId": 17
}
}
]
Now i need to filter this array on the condition of the promise, how do I do that .
This is what i have tried.
data.filter(d => d.rtbSspPublishers.get().then(res => res.name.includes('Mobile')));
But this does not seem to work. How to get the async value to work with the array filter?