I have the following setup:
Pre-Request script:
if (pm.environment.get === null){
pm.environment.set(“userEmail”, “[email protected]”);
};
And the request body:
{
“login”: “{{userEmail}}”,
“password”: “{{userPW}}”
}
To reproduce, create userEmail variable and userPW variable, then leave userEmail values blank in the environment variables.
The goal is to set it to a default email address in the event that the environment variable value has been deleted.
When I execute this, I’m being told that the email cannot be blank by the API.
The variable is set,
but the request is sent as if it was not set:
What am I doing wrong? I have tried both a function and non-function format. No improvement. To make matters worse, this was working for me just the other day (1-2 days ago) when I first implemented it and I tested it multiple times with success.
Edit: I’ve also tried using a setTimeout(1000); with no success. I might be using it wrong, though. Not really a programmer. Thanks in advance!