I'd like to count how many environment variables I have in an Environment in POSTMAN.
In my Environment called, UUID Test
, I have 10 variables that I have set:
UUID_1
UUID_2
UUID_3
..
UUID_10
I've tried a number of versions which I put into the Test field in the Request (see below)
V1:
let counter = parseInt(pm.environment.get("counter"))
console.log(counter)
V2: Using the Environment name in quotes.
let counter = parseInt(pm.environment.get("UUID Test"))
console.log(counter)
With both of these versions I am receiving a Nan
in the console. What am I missing here?
CodePudding user response:
Try
console.log(Object.keys(pm.environment.toObject()).length)
That should give you that length of the variables in the environment file.