# Are Request URL variables resolved before their pre-request script executes?

**URL:** <https://community.postman.com/t/are-request-url-variables-resolved-before-their-pre-request-script-executes/33980>\
**Category:** Help Hub\
**Tags:** variables\
**Created:** [March 28, 2022, 10:18pm UTC](https://community.postman.com/t/are-request-url-variables-resolved-before-their-pre-request-script-executes/33980 "2022-03-28T22:18:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![developerjake](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@developerjake](https://community.postman.com/u/developerjake)\
**Post date:** [March 28, 2022, 10:18pm UTC](https://community.postman.com/t/are-request-url-variables-resolved-before-their-pre-request-script-executes/33980/1 "2022-03-28T22:18:00Z")

</div>

Please study this simple example:

 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/a/a5a2c8e51b27b56c9cb2f1e7305562170cc9a4dd.png)

You will notice that the envinroment variable called `url` is successfully set to the value `"fact"`, but it is ephemeral. The sequence of events is:

1. We **set** the `url` environment variable to `"fact"` from the Request’s pre-request script.
2. We **get** the `url` environment variable, and receive `"fact"`, and log it to the console as evidence.
3. We make the Request, which binds `url` into the URL, but receive `undefined`; the URL is wrong.
4. We check the environment afterwards and find that `url` is `undefined`

The begs the following questions:

- Is the variable in the URL of the request is resolved before the pre-request script executes?
- Given that we retrieved the `url` variable during the pre-request script and logged it to the console, seeing the expected value - `"fact"`, why was the environment variable `undefined` by the time the Test ran? Was it unset immediately after it was set in the Request’s pre-request script, before the Request actually executed? If so, why?

Given the above example, this following example would suggest that the URL for the request is indeed resolved before the pre-request script is run (which is as confusing as it is vexing):

 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/d/d4c8813ab353057bff76cdf6027ab41f569a3141.png)
