How to filter response to display only not null values

Hello,

I am sending a POST request which actually GETS data. The request body is raw as below:

{
“query”: {
“value”: “",
“name”: “”,
“identifier”: “”,
“cn”: "

},
“rows”: “10000”,
“start”: “0”
}

The response is as below,

I want to filter all responses and remove the entire record where cn is null.

Can anybody help how to make that possible? Please note this is a POST request.

{
“cn”: “”,
“identifier”: “AA”,
“legalType”: “AA”,
“name”: “WSSSWWW”,
“parties”: [
{
“partyName”: “XXXXXAAA”,
“partyRoles”: [
“proprietor”
],
“partyType”: “person”,
“score”: 0.0
}
],
“score”: 1,
“status”: “ACTIVE”
},

Postman uses JavaScript under the hood, so you should be able to parse the response, and then use the JavaScript filter function to filter out the objects where cn = “”. Please note that technically is not null but an empty string.

Array.prototype.filter() - JavaScript | MDN (mozilla.org)

JavaScript Array filter() Method (w3schools.com)

You can then console log the filtered results.

However, can you please confirm how the response actually looks.

In needs to be an array as the JavaScript filter function only works against array’s.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.