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
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.