#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →

Using pm Object and JavaScript in Scripts

What Is the pm Object?

The pm object is Postman's built-in JavaScript API, available in both pre-request scripts and tests. It gives scripts access to the current request, response, variables, and environment.

Common pm Methods

MethodPurpose
pm.environment.set()Set an environment variable
pm.environment.get()Read an environment variable
pm.requestAccess or modify the outgoing request
pm.responseAccess the response data
pm.test()Define a named test assertion

Writing Basic JavaScript

Since scripts run in a standard JavaScript sandbox, ordinary JavaScript - loops, conditionals, functions - works alongside the pm object, giving full control over request setup and response handling.

With the pm object in hand, you're ready to start writing real tests and assertions against your API responses.

Ready to master Postman API Testing Course?

Join Uncodemy's hands-on training and build real-world API testing skills with expert mentors.

Explore Course