Hi,
have a doubt with setting up random values to environment level and use it.
Actually I wanted to add a random word in place of name and namekey and set it in environment level. So I have attached the code. But it’s going as undefined error always. I am not if I can do this with the below code. So my body is always dynamic so I want to generate random words/word, whenever it runs and set it and use it for other request. So that always I can have new values without input.Thanks in advance,
POST body :
[
{
“name”: “{{categoryName}}”,
“nameKey”:"{{categorynameKey}}"
}
]
Code : Pre-request Script
var random1="{{$randomLoremWords}}";
var random2="{{$randomLoremWord}}";
var categoryName=pm.environment.get(“name”) + random1
console.log(categoryName);
var categorynameKey=pm.environment.get(“nameKey”) + random2
console.log(categorynameKey);
pm.environment.set(“caetegoryName”, data[0].categoryName);
pm.environment.set(“categorynameKey”,data[0].categorynameKey);