# Collection Runner With SetNextRequest

**URL:** <https://community.postman.com/t/collection-runner-with-setnextrequest/53045>\
**Category:** Help Hub\
**Tags:** tests, collections, json\
**Created:** [October 10, 2023, 6:58am UTC](https://community.postman.com/t/collection-runner-with-setnextrequest/53045 "2023-10-10T06:58:19Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![xk0der](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/xk0der/32/2056_2.png) [@xk0der](https://community.postman.com/u/xk0der)\
**Post date:** [October 10, 2023, 8:44am UTC](https://community.postman.com/t/collection-runner-with-setnextrequest/53045/2 "2023-10-10T08:44:55Z")

</div>

Hey @nar13 👋 Welcome to the community!

`postman.setNextRequest()` does not call/execute the request immediately. It only let’s postman know which request to run after the current one finishes.

Check an earlier answer on Postman community for more details: [setNextRequest() doesn't work - #7 by amit](https://community.postman.com/t/setnextrequest-doesnt-work/17506/7)

In your case, since the control falls to the last `if..else` block, and likely `y` is less than `2` hence `postman.setNextRequest('Make Bet');` gets executed, overriding the earlier instruction to run the `Unable Bonus` request.

you can change your control flow as follows, which should make sure that only one postman.setNextRequest() is excuted, setting the right request to be executed, post completion of the current one

```auto
if (z === true) {
  ...
} else if ( y < 2)
 ...
} else {

}

```

PS: For future, it is advisable to post scripts/code as text/code-blocks, makes it easier for others to test your code 👍

---

_[View the full topic](https://community.postman.com/t/collection-runner-with-setnextrequest/53045)._
