Having a hard time Setting a Environment Variable in Postman which contains another already stored environment variable.
Currently, in my Pre-Request Script I've created and set a Environment variable called random_number.
Pre-Request Script:
const num = pm.variables.replaceIn("{{$randomInt}}") * 5 + 1;
pm.environment.set("random_number", num);
I know this works because I can view it on the console.log w/ the following code:
console.log(pm.variables.get('random_number'));
---> 3731
However, when I try Creating a new Environment variable with the following code (and with many different variations) I receive a TypeError:
Version 1:
pm.variable.get('random_number')
pm.environment.set("newpw", "NewPW " + random_number +" !");
console.log(pm.variables.get("newpw"));
Version 2:
pm.variable.get('random_number')
pm.environment.set("newpw", (NewPW{{random_number}}!));
console.log(pm.variables.get("newpw"));
Version 3:
pm.variable.get('random_number')
pm.environment.set("newpw", "NewPW " {{random_number}} " !");
console.log(pm.variables.get("newpw"));
Most of the time the TypeError I'm receiving has something to do with the .get but I'm sure I'm not formatting/setting the environment variable that includes there 1st variable ('random_number') correctly.