# setNextRequest - won't stop on null

**URL:** <https://community.postman.com/t/setnextrequest-wont-stop-on-null/38391>\
**Category:** Help Hub\
**Tags:** collections, setnextrequest\
**Created:** [August 21, 2022, 4:03pm UTC](https://community.postman.com/t/setnextrequest-wont-stop-on-null/38391 "2022-08-21T16:03:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![daniel.sessions](https://avatars.discourse-cdn.com/v4/letter/d/47e85d/32.png) [@daniel.sessions](https://community.postman.com/u/daniel.sessions)\
**Post date:** [August 21, 2022, 4:03pm UTC](https://community.postman.com/t/setnextrequest-wont-stop-on-null/38391/1 "2022-08-21T16:03:13Z")

</div>

Hello

I run a collection that uses postman.setNextRequest() in a pre-req script to set the page id param value on my next request. This works fine until the last request in the collection where the if…else statement should stop when the nextPageId response is null. Instead, an additional request is made with the nextPageId set as null. Is there another way I should set my statement to stop this final request? Thanks

Request:  
GET {{baseUrl}}users?pageId={{nextPageId}}

Pre-req script:  
const nextPageId = pm.variables.get(‘nextPageId’);  
if (nextPageId !== null) {  
postman.setNextRequest(‘Users\_nextPage’);  
} else {  
postman.setNextRequest(null);  
}

Response  
{  
“limit”: 100,  
“nextPageId”: null,  
“content”:   
}
