# Saving environment variables in an array

**URL:** <https://community.postman.com/t/saving-environment-variables-in-an-array/18479>\
**Category:** Help Hub\
**Tags:** variables\
**Created:** [December 15, 2020, 10:18am UTC](https://community.postman.com/t/saving-environment-variables-in-an-array/18479 "2020-12-15T10:18:18Z")\
**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:** [December 15, 2020, 10:26am UTC](https://community.postman.com/t/saving-environment-variables-in-an-array/18479/2 "2020-12-15T10:26:25Z")

</div>

With the current JSON response provided, the below snippet could work.

```auto
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](https://us1.discourse-cdn.com/getpostman/original/3X/f/6/f68a08437599174af162fb71bcc195c4be471fbe.png)

---

_[View the full topic](https://community.postman.com/t/saving-environment-variables-in-an-array/18479)._
