# Help needed with "ReferenceError: 'xyz' is not defined"

**URL:** <https://community.postman.com/t/help-needed-with-referenceerror-xyz-is-not-defined/48430>\
**Category:** Help Hub\
**Tags:** variables, moment\
**Created:** [June 12, 2023, 10:07am UTC](https://community.postman.com/t/help-needed-with-referenceerror-xyz-is-not-defined/48430 "2023-06-12T10:07:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![meatinaplasticsack](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/meatinaplasticsack/32/13383_2.png) [@meatinaplasticsack](https://community.postman.com/u/meatinaplasticsack)\
**Post date:** [June 12, 2023, 10:07am UTC](https://community.postman.com/t/help-needed-with-referenceerror-xyz-is-not-defined/48430/1 "2023-06-12T10:07:08Z")

</div>

Hello!

I was reading interesting and very helpful [blog article](https://dannydainton.com/2018/05/21/hold-on-wait-a-moment/) by @danny-dainton related to moment.js and I have problem with my pre-request script.

_What am I doing wrong here? Why “created\_before” is not defined?_

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

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [June 12, 2023, 10:33am UTC](https://community.postman.com/t/help-needed-with-referenceerror-xyz-is-not-defined/48430/2 "2023-06-12T10:33:40Z")

</div>

You’re trying to log out _local_ variables `created_before` / `created_after` but these are not defined.

As you’re creating _environment_ variables, you would need to reference those by using:

```javascript
console.log(pm.environment.get('created_before'))

```

Similar to how you are doing this on line 12 of the script.

---

<div class="post-metadata">

**Author:** ![meatinaplasticsack](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/meatinaplasticsack/32/13383_2.png) [@meatinaplasticsack](https://community.postman.com/u/meatinaplasticsack)\
**Post date:** [June 12, 2023, 11:47am UTC](https://community.postman.com/t/help-needed-with-referenceerror-xyz-is-not-defined/48430/3 "2023-06-12T11:47:44Z")

</div>

You’re right, now it works as it should be. 🙂

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/7/4/74de314ae691785a4168e118091cf02317be73e7.png)

Thank you for quick help and valuable blog post - it was VERY helpful and easy to understand. 👏 🙂 :
