# Setting variables in node from response/globals/environment variables

**URL:** <https://community.postman.com/t/setting-variables-in-node-from-response-globals-environment-variables/7102>\
**Category:** Help Hub\
**Created:** [August 12, 2019, 6:11am UTC](https://community.postman.com/t/setting-variables-in-node-from-response-globals-environment-variables/7102 "2019-08-12T06:11:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jraff](https://avatars.discourse-cdn.com/v4/letter/j/67e7ee/32.png) [@jraff](https://community.postman.com/u/jraff)\
**Post date:** [August 12, 2019, 6:11am UTC](https://community.postman.com/t/setting-variables-in-node-from-response-globals-environment-variables/7102/1 "2019-08-12T06:11:08Z")

</div>

Hi,

I’m using newman as a node module and I’m trying to either set a global/environment variable as a js variable or access & parse the response and set it as a variable that way - I can’t find anything in the reference material that explains how to do this. I did find exportGlobals: require(‘xxx.json’); - but this doesn’t seem to actually update the specified json file at all (the variable in question has no value set).

My actual use case is:  
I get sent a collection name as part of a request to my node server, I send the collection name to the ‘Single Collection’ postman API: [https://www.getpostman.com/collections/8a54de8f97aab0f5722c](https://www.getpostman.com/collections/8a54de8f97aab0f5722c)  
This returns the UID which I then use to run the collection in question. The variable I’m trying to set is the UID - either by setting it as a global/environment variable then exporting and parsing the file, or by directly parsing the response.

Does anyone know a way to do this?

---

<div class="post-metadata">

**Author:** ![vdespa](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/vdespa/32/2770_2.png) [@vdespa](https://community.postman.com/u/vdespa)\
**Post date:** [August 12, 2019, 2:21pm UTC](https://community.postman.com/t/setting-variables-in-node-from-response-globals-environment-variables/7102/2 "2019-08-12T14:21:02Z")

</div>

I am having a hard time understanding exactly what you are trying to do.

Have you tried setting the variable in your Tests like pm.globals.set(uuid, response.something);

---

<div class="post-metadata">

**Author:** ![jraff](https://avatars.discourse-cdn.com/v4/letter/j/67e7ee/32.png) [@jraff](https://community.postman.com/u/jraff)\
**Post date:** [August 13, 2019, 10:16am UTC](https://community.postman.com/t/setting-variables-in-node-from-response-globals-environment-variables/7102/3 "2019-08-13T10:16:51Z")

</div>

Hi vdespa,

I’m trying to assign variables in node (when running my ‘index.js’ file) from the responses I get during a collection run.

EDIT: I’ve worked out what I was looking for: summary.response.json() - that gives me the response body as json.
