# Loop a post request

**URL:** <https://community.postman.com/t/loop-a-post-request/10040>\
**Category:** Help Hub\
**Created:** [January 13, 2020, 8:46am UTC](https://community.postman.com/t/loop-a-post-request/10040 "2020-01-13T08:46:01Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Sandokhan](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@Sandokhan](https://community.postman.com/u/Sandokhan)\
**Post date:** [January 13, 2020, 2:02pm UTC](https://community.postman.com/t/loop-a-post-request/10040/2 "2020-01-13T14:02:23Z")

</div>

@theToncheff in this other post you can find one way to solve your problem, I guess!

> [@How to store a JSON in a variable and use it in the request body?](https://community.postman.com/t/how-to-store-a-json-in-a-variable-and-use-it-in-the-request-body/1881/11):
>
> In the first request, on test I’ll put this code: let Cities = JSON.parse(responseBody), CityIds = \_.map(body, (city) =\> city.id); // Store all the Cities Ids in the environment variable pm.environment.set('CityIdsList', JSON.stringify(CityIds)); // Store the next index of the array for City ids pm.environment.set('nextIndex', 0); // Store the active City ID pm.environment.set('activeCityId', CityIds[0]); Then, on the second request I’ll use this one: let CityIds = JSON.parse(pm.environme…

Look out and see if fits you!

🕶

---

_[View the full topic](https://community.postman.com/t/loop-a-post-request/10040)._
