# PM Sendrequest return value to collectionvariable

**URL:** <https://community.postman.com/t/pm-sendrequest-return-value-to-collectionvariable/18835>\
**Category:** Help Hub\
**Tags:** tests, variables, json\
**Created:** [January 4, 2021, 4:33pm UTC](https://community.postman.com/t/pm-sendrequest-return-value-to-collectionvariable/18835 "2021-01-04T16:33:04Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![bpricilla](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/bpricilla/32/6511_2.png) [@bpricilla](https://community.postman.com/u/bpricilla)\
**Post date:** [January 5, 2021, 1:32am UTC](https://community.postman.com/t/pm-sendrequest-return-value-to-collectionvariable/18835/2 "2021-01-05T01:32:38Z")

</div>

Hello @pr85, I believe it should be possible and the same sort of query is answered in the link below:

> [@Saving environment variables in an array](https://community.postman.com/t/saving-environment-variables-in-an-array/18479/2):
>
> With the current JSON response provided, the below snippet could work. var jsonData = JSON.parse(responseBody); console.log(jsonData[0].site); pm.environment.set("site1", jsonData[0].site); siteArray = []; for (var i=0; i\<jsonData.length; i++) { var site = jsonData[i].site; //console.log(jsonData[i].site) siteArray.push(`${site}`); } console.log(siteArray); [image]

May be you just need to tweak a bit since you are storing the values from sendrequest and the variable scope is at collection level.

Hope this helps 😊

---

_[View the full topic](https://community.postman.com/t/pm-sendrequest-return-value-to-collectionvariable/18835)._
