I have a response body that looks like this
{
"data_sets":[
{
"author": {
"name": "foo"
},
"category": "zip",
"client": true,
"data_type": "zip",
"index": "completed",
"id": 200,
"params": {}
},
{
"author": {
"name": "foo2"
},
"category": "zip",
"client": true,
"data_type": "zip",
"index": "completed",
"id": 190,
"params": {}
}]}
I am trying to iterate over my thousands of datasets in my postman test and just simply console.log the id that equals the id in my environmental variable. For this case, let's say that is 190. I'm trying something like this but it isn't working. It isn't failing but it's not giving me my expected output.
Here is my code in postman
pm.test("the response has the right id", () => {
id_dataset = pm.environment.get("id");
var jsonData = pm.response.json();
for(var i = 0; i < jsonData.data_sets.length; i++)
if(jsonData.data_sets[i].id == id_dataset)
console.log(jsonData.data_sets[i].id);
});
Can anyone help with this?