Good night, I'm trying to make a variable to use in another request and I'm testing.
I made an array with the code attribute coming from my payload, it contains 4 codes from 1 to 4 so my array are 4 positions. I made a variable to save the Array values.
When I call GetGlobal within the same function where I did it, the return of the arrays is correct, from 1 to 4.
But if I call GetGlobal in another method or out of function it simply returns me all 4 and not the array with the positions, can someone help me? I would appears like 1,2,3,4 and not just the number 4.
let responseJson = JSON.parse(responseBody); let array = [];
pm.test("Testing",function(){
for(var value in responseJson){
trab = responseJson[value].code;
pm.globals.set("testCode",trab);
console.log(pm.globals.get("testCode");
}});
// THE RESULT IS 1,2,3,4.
pm.test("Testing 2",function(){
for(var i=0;i<4;i++){
console.log(pm.globals.get("testCode");
}});
// THE RESULT IS 4,4,4,4 AND NO 1,2,3,4.
Where I'm wrong????
Aucun commentaire:
Enregistrer un commentaire