Error: Error in package "undefined" is not valid JSON

Everything looks fine but i m getting err. but function is working fine in the post-response script
Response script

const myPackage = pm.require('@aa-bb-cc/dtables');
myPackage.YY('zz');

Package script:

var responseBody = pm.response.json();

function YY(action) {
    if (action == "zz"){
        pm.test("tested", function () {
             console.log("insode loop1");
    });
    }
}

module.exports = { YY }

use below instead of myPackage.YY(‘zz’);

const dummy = pm.require('@aa-bb-cc/dtables');

console.log(dummy.YY("zz"))

and in package :

function YY(action) {
    if (action == "zz") {
        pm.test("tested", function () {
            console.log("insode loop1");
        });
    }
}

module.exports = { YY }
1 Like