Public scripts
Usage
Manage public scripts
Reference public scripts
Referencing public scripts in other scripts
pm.sendRequest
or pm.environments.set
cause they will fail. We recommend writing pure functions and returning them.var
, let
, const
, or function
other scripts cannot call those variables and methods. You must convert a variable or method to a global variable or global method if you want other scripts to use it.
Practical Example
Example: Declare a Simple Global Function
Define a global function within a public script so that it can be accessed by other scripts.
Call the Public Script
In the Pre Processors or Post Processors tab of an endpoint, first add the public script. Then, add a custom script and call the function declared in the public script.
Note: The public script must be added first in order for its methods to be accessible in subsequent custom scripts.
Modified atΒ 2025-06-11 04:06:44