javascript policy use node dependencies throw Javascript runtime error: "ReferenceError: "require" is not defined

fechen
Participant I

Hi,

I am working on add two javascript callout policy into the proxies endpoint preflow/postflow.

However, the javascript callout code needs to require some node dependencies. So I add node package.json under resource and also installed the node dependencies via management api.

When test the endpoint, it throws exception Javascript runtime error: "ReferenceError: "require" is not defined.

Under the resource, I have two folders, one is 'jsc' folder containing the javascript file and anther node folder containing the zip files of dependencies and package.json.

I am not sure whether I can create javascript policy using node js file.

Thanks!

0 1 164
1 REPLY 1

The JS callout does not run in a node environment.

You can use a hosted Target for a node environment.

Or run your code in a node hosting environment.