# Extract a string from array response

**URL:** <https://community.postman.com/t/extract-a-string-from-array-response/26109>\
**Category:** Help Hub\
**Tags:** tests, variables\
**Created:** [July 23, 2021, 4:55pm UTC](https://community.postman.com/t/extract-a-string-from-array-response/26109 "2021-07-23T16:55:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rav.adonis](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/rav.adonis/32/9253_2.png) [@rav.adonis](https://community.postman.com/u/rav.adonis)\
**Post date:** [July 23, 2021, 4:55pm UTC](https://community.postman.com/t/extract-a-string-from-array-response/26109/1 "2021-07-23T16:55:53Z")

</div>

Hello all,

I’m trying to extract a single property filed from each object of array and pass on to another GET request.

Below is the response and from the response, I need to extract all the `"name"` field and iterate them to another request like below

`GET https://BASE_URL/api/v1/{{name}}`

```auto
[
     {
           "name": "User1",
            "realm": "ldap"
     },
     {
           "name": "User2",
            "realm": "ldap"
     },
     {
           "name": "User3",
            "realm": "ldap"
     }
]

```

I have tried the below one:

```auto
var data = JSON.parse(responseBody);
postman.setEnvironmentVariable("User", data[0].name);

```

This is storing all the user name like `["User1", "User2", "User3"]` But I’m not sure how to iterate them. Please help me on this. Thanks in advance.

---

<div class="post-metadata">

**Author:** ![taehoshino](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/taehoshino/32/6608_2.png) [@taehoshino](https://community.postman.com/u/taehoshino)\
**Post date:** [July 26, 2021, 2:27am UTC](https://community.postman.com/t/extract-a-string-from-array-response/26109/2 "2021-07-26T02:27:44Z")

</div>

Hey @rav.adonis 👋 Welcome to the Postman Community 🚀

You can loop over a request using `array.shift()` and `postman.setNextRequest()` by dynamically updating an array. I have created [a sample collection](https://www.postman.com/speeding-resonance-133102/workspace/how-to-s-workspace/collection/12689164-25ccdc45-b1b4-483a-85d9-8b7cf9f69799?ctx=documentation) in my Public Workspace to demonstrate this.

I hope this helps! 😃 Let me know if you have further questions!
