Skip to content
This repository has been archived by the owner on Sep 23, 2021. It is now read-only.

How to set up pre-request script #25

Open
mklinko opened this issue Mar 6, 2017 · 0 comments
Open

How to set up pre-request script #25

mklinko opened this issue Mar 6, 2017 · 0 comments

Comments

@mklinko
Copy link

mklinko commented Mar 6, 2017

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant