# Is there a easy way to define functions to use across multiple requests that is not the eval

**URL:** <https://community.postman.com/t/is-there-a-easy-way-to-define-functions-to-use-across-multiple-requests-that-is-not-the-eval/9272>\
**Category:** Help Hub\
**Tags:** tests, scripts, npm, package-library\
**Created:** [November 27, 2019, 7:51am UTC](https://community.postman.com/t/is-there-a-easy-way-to-define-functions-to-use-across-multiple-requests-that-is-not-the-eval/9272 "2019-11-27T07:51:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cstmgl](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/cstmgl/32/3162_2.png) [@cstmgl](https://community.postman.com/u/cstmgl)\
**Post date:** [November 27, 2019, 7:51am UTC](https://community.postman.com/t/is-there-a-easy-way-to-define-functions-to-use-across-multiple-requests-that-is-not-the-eval/9272/1 "2019-11-27T07:51:05Z")

</div>

hi all, I’m here to see if there is a better way of doing “How to reuse Postman scripts and tests among different test cases” without using the eval method?

I want to do something like why described here: [open to define global functions to be used across collection · Issue #959 · postmanlabs/postman-collection · GitHub](https://github.com/postmanlabs/postman-collection/issues/959) and I would like to do it in a more structured way then using eval and global variables.

can someone maybe guide me in a way I could do this? or is eval really the only way to go?

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [April 14, 2025, 3:53pm UTC](https://community.postman.com/t/is-there-a-easy-way-to-define-functions-to-use-across-multiple-requests-that-is-not-the-eval/9272/2 "2025-04-14T15:53:05Z")

</div>

Hey everyone 👋,

Sorry we didn’t get to this sooner. This isn’t the experience we want for our users.

I believe this is what you’re looking for and was added as part of the major version 11 release last year.

> **[Add internal scripts to the Package Library in Postman | Postman Docs](https://learning.postman.com/docs/tests-and-scripts/write-scripts/packages/package-library/)**
>
> Postman is a collaboration platform for API development. Postman's features simplify each step of building an API and streamline collaboration so you can create better APIs—faster.

We have also just released support for external packages in the latest version of Postman, you can read more about this here:

> <https://github.com/postmanlabs/postman-app-support/issues/13542>
>
> We’re excited to announce a powerful new capability in Postman’s scripting envir…onment — support for \*\*external public packages from the \[NPM\](https://www.npmjs.com/) and \[JSR\](https://jsr.io/) registries\*\*! 🎉
> 
> With this release, you can now seamlessly supercharge your pre-request and post-response scripts using your favorite open-source packages right from inside Postman.
> 
> 
> \## 📽️ Feature Walkthrough
> 
> Getting up and running is easy:
> 1. Open the \*\*Scripts\*\* tab (Pre-request or Post-response) for any HTTP Request.
> 2. Click on the \*\*Packages\*\* dropdown to search and select a package from \*\*NPM\*\* or \*\*JSR\*\*.
> 3. Or, directly import packages into your script using \[pm.require\](https://learning.postman.com/docs/tests-and-scripts/write-scripts/postman-sandbox-api-reference/#import-packages-from-scripts). Examples:
> \`\`\`js
> // From NPM
> const lodash = pm.require("npm:lodash@4.17.21");
> 
> // From JSR
> const shortUUID = pm.require("jsr:@opensrc/short-uuid")
> \`\`\`
> 
> https://github.com/user-attachments/assets/c39c4951-f92d-4477-8b68-f2a573c80141
> 
> \> 📚 Read the \[full documentation here\](https://learning.postman.com/docs/tests-and-scripts/write-scripts/packages/external-package-registries/) for more examples, caveats, and advanced usage.
> 
> \## 🛠️ Planned Work Ahead
> 
> We’re just getting started! Here's what we're working on next:
> \- \*\*Adding auto-suggestions\*\* in the scripts tab for packages you import — making it even easier to discover and use package APIs as you type.
> \- \*\*Extending package support across all protocols\*\*, including gRPC, GraphQL, etc.
> \- \*\*Bringing this feature to Postman CLI and Monitors\*\* so your workflows stay consistent across all Postman tools.
> 
> Stay tuned! 💥
> 
> \## ⚠️ Known Limitations
> 
> While this is a huge leap forward, here are a few limitations to be aware of:
> \- Postman's script environment is platform-agnostic. This means Packages that rely on \[Node.js built-ins\](https://nodejs.org/api/modules.html#built-in-modules) like \`child\_process\` or \`worker\_threads\` may not work as expected. We offer best-effort implementations of Node built-ins, but they may not have complete parity with Node.js.
> \- Packages that reference globals outside the \[allowed sandbox environment\](https://learning.postman.com/docs/tests-and-scripts/write-scripts/postman-sandbox-api-reference/#use-global-objects) may not behave correctly, depending on the part of the package that is executed.
> \- Packages that use Top-level \`await\` are not supported at the moment.
> 
> \## 🙌 Thank You!
> 
> This was long overdue and wouldn’t have been possible without the incredible feedback and support from our Postman community. Your insights and use cases helped shape this—please keep it coming!
> 
> Happy Scripting!

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [April 14, 2025, 3:53pm UTC](https://community.postman.com/t/is-there-a-easy-way-to-define-functions-to-use-across-multiple-requests-that-is-not-the-eval/9272/3 "2025-04-14T15:53:35Z")

</div>

Closed on April 14, 2025, 3:53pm UTC


