Best practices for using current timestamp across collection requests #4413
-
Using current timestamp variable across collection requestsI've recently migrated from Postman to Bruno and created several collections. In one of my collections, I need to include the current date and time in a specific format ( Currently, I'm adding this code to each request's const moment = require("moment");
const now = moment().format("YYYY-MM-DD HH:mm:ss");
bru.setEnvVar("now", now); Then I use Is there a way to define this timestamp variable once at the collection level so it's always available and up-to-date for all requests within that collection? I'm looking for a more DRY approach that would automatically provide an updated timestamp whenever any request in the collection is executed. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You can add the script to the collection pre-request script, then it will be executed before every request. Hover over the collection -> Click on the Three Dots -> Settings -> Script. |
Beta Was this translation helpful? Give feedback.
You can add the script to the collection pre-request script, then it will be executed before every request. Hover over the collection -> Click on the Three Dots -> Settings -> Script.