How to set up pre-request script
mklinko opened this issue · 0 comments
have one question regarding one thing which I am making in Postman. The situation next:
I have Post request with JSON:
{
"title":"TITLE", // It is just a name
"coordinate1":coordinate,
"coordinate2":coordinate
}
I would like to create new object with new random name when I do POST request.
I have created JS code to generate new name (Please look on it).
var randomString = randomString(7)
function randomString(len, charSet) {
charSet = charSet || 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var randomString = '';
for (var i = 0; i < len; i++) {
var randomPoz = Math.floor(Math.random() * charSet.length);
randomString += charSet.substring(randomPoz,randomPoz+1);
}
return randomString;
}
But I did not get how use it ((. Which next steps should I make to getthe desired result? Should I set a variable env or someting else?
Thanks a lot.