# Save response to global variable for use with other queries

**URL:** <https://community.postman.com/t/save-response-to-global-variable-for-use-with-other-queries/14347>\
**Category:** Help Hub\
**Created:** [July 21, 2020, 10:25pm UTC](https://community.postman.com/t/save-response-to-global-variable-for-use-with-other-queries/14347 "2020-07-21T22:25:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![larry](https://avatars.discourse-cdn.com/v4/letter/l/47e85d/32.png) [@larry](https://community.postman.com/u/larry)\
**Post date:** [July 21, 2020, 10:25pm UTC](https://community.postman.com/t/save-response-to-global-variable-for-use-with-other-queries/14347/1 "2020-07-21T22:25:54Z")

</div>

I am trying to retrieve a get result and automatically store it in an environment variable for use by other queries. Does anyone have a working example that would help?

---

<div class="post-metadata">

**Author:** ![kevin.swiber](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/kevin.swiber/32/3820_2.png) [@kevin.swiber](https://community.postman.com/u/kevin.swiber)\
**Post date:** [July 21, 2020, 10:33pm UTC](https://community.postman.com/t/save-response-to-global-variable-for-use-with-other-queries/14347/2 "2020-07-21T22:33:42Z")

</div>

Hey @larry,

Something like this should work. Under the Tests tab, write:

```auto
pm.environment.set('savedResponse', JSON.stringify(pm.response.json()));

```

Then to access it in a subsequent request, you can use:

```auto
const saved = JSON.parse(pm.environment.get('savedResponse'));

```

in a script or you can just use normal variable syntax, such as `{{savedResponse}}` in other parts of the Request that support variable substitution.

Hope this helps.

Best,

Kevin
