Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

204
Views
Set a Environment Variable with another environment variable inside (Postman / Test Script)

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.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!