Hi there. I have a bunch of requests that I would like to submit with random data. I already have in place some Pre-request Scripts to do this, but I was wondering if it would be possible to refactor those and make the whole collection a bit cleaner.
Right now, I have a several Pre-request scripts like these (either to generate a random float number or do something else) for some of the request fields:
pm.variables.set("Foo", _.random(20, 150, true));
pm.variables.set("Bar", _.random(20, 150, true));
pm.variables.set("Baz", _.random(20, 150, true));
...
As you can see, every single field must have the same range for the random function. If I put this in the collection Pre-request Script, all of those will have the exact same value, which is not what I want.
What I would like to accomplish, is to have a function (or some similar functionality) somewhere that can be run for each field of the request.
I guess one way to put it, is to have something similar to the built-in dynamic variables. For instance, something like this:
{
"Foo": "{{RandomFloat(20, 150)}}",
"Bar": "{{RandomFloat(20, 150)}}",
"Baz": "{{RandomFloat(20, 150)}}",
...
}
Thanks!