How can I always run a request when a collection is opened? #5719
-
|
I have an authentication request that generates a token valid for a few hours. I need to run this script just once every time I open the app/collection. In this authentication request, I have a post request script that sets the required secrets which all other scripts in the collection can use. Rather than spamming the server and generating a new token for every request (using pre request scripts), is there a way to have a script run only once (when bruno/this collection is opened)? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
You can add a pre-request script on the collection level that checks if the Token is already set. If it's not set, you can use |
Beta Was this translation helpful? Give feedback.
-
|
You could also use bru.sendrequest() or bru.runRequest() as Timon mentioned |
Beta Was this translation helpful? Give feedback.
You could also use bru.sendrequest() or bru.runRequest() as Timon mentioned