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

**URL:** <https://community.postman.com/t/error-error-in-package-undefined-is-not-valid-json/60794>\
**Category:** Help Hub\
**Tags:** tests, package-library\
**Created:** [May 8, 2024, 5:08am UTC](https://community.postman.com/t/error-error-in-package-undefined-is-not-valid-json/60794 "2024-05-08T05:08:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![payload-geoscienti29](https://avatars.discourse-cdn.com/v4/letter/p/96bed5/32.png) [@payload-geoscienti29](https://community.postman.com/u/payload-geoscienti29)\
**Post date:** [May 8, 2024, 5:08am UTC](https://community.postman.com/t/error-error-in-package-undefined-is-not-valid-json/60794/1 "2024-05-08T05:08:00Z")

</div>

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

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

```

**Package script:**

```auto
var responseBody = pm.response.json();

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

module.exports = { YY }

```

---

<div class="post-metadata">

**Author:** ![shid19nov](https://avatars.discourse-cdn.com/v4/letter/s/c4cdca/32.png) [@shid19nov](https://community.postman.com/u/shid19nov)\
**Post date:** [May 8, 2024, 5:21am UTC](https://community.postman.com/t/error-error-in-package-undefined-is-not-valid-json/60794/2 "2024-05-08T05:21:13Z")

</div>

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

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

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

```

and in package :

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

module.exports = { YY }

```

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [June 7, 2024, 5:21am UTC](https://community.postman.com/t/error-error-in-package-undefined-is-not-valid-json/60794/3 "2024-06-07T05:21:39Z")

</div>

Closed on June 7, 2024, 5:21am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
