Hi, im new in Postman. I have two arrays for example var a = [βxβ,βYβ] and var b = [β1β,β2β] iβd like to send request for each combiination something like for loop in for loop. I can send requests with one array but i canβt do it with two arrays.
What is easiest way to do it?
Thanks in advance.
First of all, line 3 in what Iβm assuming is your pre-request script looks incorrect.
Iβm guessing that states is the outer loop and zip codes is the inner loop.
My recommendation is to not have two loops for something you can do with one loop if you format your input data appropriately. I suggest creating an array of objects for your input data.
Something similar to the followingβ¦
[
{
"Palm Beach": "33411"
},
{
"Palm Beach": "33428"
},
{
"Charlotte": "33446"
},
{
"Charlotte": "33476"
},
{
"Collier": "33982"
}
]
This way, when you run the array shift you will get both elements in an object in your current variable and can do something similar to the following to retrieve the data that you are going to save as varibles for the request.
let currentObject = pm.environment.get("testData");
console.log(currentObject);
let currentState = Object.keys(currentObject); // should return the keyname
let currentZip = currentObject[currentState]; // should return the value
console.log(currentState);
console.log(currentZip);
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.