How to Write Global Functions in Postman

Without eval: Define an object containing your function(s) in the collection’s pre-request scripts without using let, var, etc. This attaches it to Postman’s global sandbox object. utils = { myFunc: function() { return ‘hello’; } }; Then within your request’s pre-request or test script section just call the function: console.log(utils.myFunc());