# Looping over request don't loop

**URL:** <https://community.postman.com/t/looping-over-request-dont-loop/47461>\
**Category:** Help Hub\
**Created:** [May 15, 2023, 9:35am UTC](https://community.postman.com/t/looping-over-request-dont-loop/47461 "2023-05-15T09:35:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![comtenaab](https://avatars.discourse-cdn.com/v4/letter/c/ecc23a/32.png) [@comtenaab](https://community.postman.com/u/comtenaab)\
**Post date:** [May 15, 2023, 9:35am UTC](https://community.postman.com/t/looping-over-request-dont-loop/47461/1 "2023-05-15T09:35:58Z")

</div>

Hello,

I request an first API to post an action.  
I make a loop on a second API to know the status of the action.

But this one doesn’t work.

```auto
resultat = pm.response.json();
console.log(resultat.status)

if (resultat.status != "IN_PROGRESS") {
    // No customer was returned, so don't run the rest of the collection
    console.log("Boucle")
    pm.collectionVariables.set('status_job', resultat.status);
    postman.setNextRequest("Liste_Snapshot");
}
else {
    console.log("Relance")
    postman.setNextRequest("Detail_Job");
}

```

I put this code in the tests tab.

When i execute my collection, it’s play the fist API once and repeat the second only one time.

I don’t understand why, i follow some documents.

Anyone can help me?

Kind regards,  
Thomas
