How to extract site values "london" , "manchester " and "Birmingham" from an Array and save the values in an array variable in postman.
CodePudding user response:
You can use lodash
function to do it.
const res = pm.response.json();
let sites = _.map(res, _.property("site"));
//or
let sites = _.map(res, "site"));
CodePudding user response:
//Set as environment variable
var sites = response.json()["sites"];
pm.environment.set("sites", sites);
//Set as global variable
var sites = response.json()["sites"];
pm.globals.set("sites", sites);
//Set as collection variable
var sites = response.json()["sites"];
pm.collectionVariables.set("sites", sites);