I have a JSON body response that has an array object in it.
{
"tokens": [
{
"baseValue": "need this value to be extracted"
}
]
}
The following test script is not able to extract it and set it in the environment variable
var jsonData = JSON.parse(responseBody);
pm.test('get value from Response', function(){
if ( jsonData.tokens.hasOwnProperty("baseValue") ) {
var xauth = jsData.tokens.baseValue;
postman.setEnvironmentVariable("xauth", xauth);
}
});
What is wrong? Can someone help me achieve this