Need help in setting the environment variable when one of the json value changes

The following is the response of one of the API’s . I need to fetch the id when baseType is set 2 . Could anyone guide me on how to set the environment variable for the same

[
{
“Value”: 123,
“baseType”: 1,
“id”: “df214cb4-8e8a-4612-ac76-52c23f89881d”
},
{
“Value”: 1234,
“baseType”: 1,
“id”: “df214cb4-8e8a-4612-ac76-52c23f69881d”

      },
 {
    "Value": 134,
   "baseType": 2,
    "id": "df214cb4-7e8a-4612-ac76-52c23f69881d"        
   },

If I understand the ask, you want to set an environment variable to the id of whatever result has the baseType of 2. Here is how you would do that in javascript:

let responseArray = response.values; //This is the json you have in your post
let newBaseType = responseArray.find(ra => ra.baseType === 2);
if(newBaseType){
  pm.environment.set("baseTypeId", newBaseType.id);
}

If there are multiple results with baseType of 2, it will set the variable to the first one it finds.

Thanks a lot , Will give a try and update on this