# Why Postman.setPreviousRequest() not exist?

**URL:** <https://community.postman.com/t/why-postman-setpreviousrequest-not-exist/3608>\
**Category:** Help Hub\
**Created:** [December 14, 2018, 7:10pm UTC](https://community.postman.com/t/why-postman-setpreviousrequest-not-exist/3608 "2018-12-14T19:10:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![michelics](https://avatars.discourse-cdn.com/v4/letter/m/90ced4/32.png) [@michelics](https://community.postman.com/u/michelics)\
**Post date:** [December 14, 2018, 7:10pm UTC](https://community.postman.com/t/why-postman-setpreviousrequest-not-exist/3608/1 "2018-12-14T19:10:23Z")

</div>

I have a collection with invalid scenarios, to simulate bad request about required fields.  
But before to send my request I need generate a number\_token.

Collection Ex.:  
Post token card \>\> generate a number\_token to next request  
Post save card, using valid number\_token above, but without field experation\_month

Post token card \>\> generate a number\_token to next request  
Post save card, using valid number\_token above, but without field experation\_year

Post token card \>\> generate a number\_token to next request  
Post save card, using valid number\_token above, but without field cardholder\_name

There’s a way to set a “Previous Request”, in Pre-request Script, that no need repeat the request to generate a number\_token?

Ex.:  
Post token card \>\> generate a number\_token to next request  
Post save card, using valid number\_token above, but without field experation\_month  
Post save card, using valid number\_token above, but without field experation\_year  
Post save card, using valid number\_token above, but without field cardholder\_name

---

<div class="post-metadata">

**Author:** ![matt](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/matt/32/2562_2.png) [@matt](https://community.postman.com/u/matt)\
**Post date:** [December 14, 2018, 7:18pm UTC](https://community.postman.com/t/why-postman-setpreviousrequest-not-exist/3608/2 "2018-12-14T19:18:46Z")

</div>

If I understand correctly, you’d like to make the same request before running every request in a collection.

You could add a Pre-request script to your entire collection:  
[https://learning.getpostman.com/docs/postman/scripts/pre\_request\_scripts/#adding-a-pre-request-script-to-a-collection-or-folder](https://learning.getpostman.com/docs/postman/scripts/pre_request_scripts/#adding-a-pre-request-script-to-a-collection-or-folder)

In your Pre-request script you can use pm.sendRequest to generate your token and save it in a [variable](https://learning.getpostman.com/docs/postman/environments_and_globals/variables#accessing-variables-through-scripts) ready for when the request runs:  
[https://learning.getpostman.com/docs/postman/scripts/postman\_sandbox\_api\_reference/#pmsendrequest](https://learning.getpostman.com/docs/postman/scripts/postman_sandbox_api_reference/#pmsendrequest)
