Pre processor scripts
A pre processor script is a code snippet that is executed before the request is sent. This is useful when you want to include a timestamp in the request header or send a random alphanumeric string in the URL parameters.
Example
You can use the value returned to set the environment variable in order to include the current timestamp in the request header.
Set the value of the parameter timestamp as {{timestamp}}
. When the request is sent, the preprocessor script will be executed, the value of the environment variable timestamp will be set and replaced with the current timestamp
.
:::tip TIP
The corresponding environment must be selected when setting an environment variable.
The preprocessor script is written in JavaScript and has exactly the same syntax as the postprocessor script. However, there is no pm.response
object.
:::