Search code examples
javascriptpostman

Postman create class


My goal is really simple. I would like to create a class named Helper to store all common data/methods for my collection.

This is how I planned to do : enter image description here

In the main pre-request Script this is the code :

var HELPER = pm.globals.get("HELPER");

console.log(HELPER.mandatory);
console.log(HELPER.checkIfEmpty());

I'm able to retrieve the mandatory variable but I cannot call checkIfEmpty

I get the following message: TypeError: HELPER.checkIfEmpty is not a function

As you can see, this method exist.

I checked this link but without success ...

Do you have any idea what I missed ??


Solution

  • I found a way to manage what I expected :

    enter image description here

    and the main pre-request Script code :

    console.log(helper.mandatorySubIssues());
    console.log(helper.checkIfEmpty("Hello World"));