Home > OS >  How to extract different values in array and save it in a Variable in postman
How to extract different values in array and save it in a Variable in postman

Time:12-20

How to extract site values "london" , "manchester " and "Birmingham" from an Array and save the values in an array variable in postman.

allt

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);
  • Related