Hi Team,
Please advise, how we can use xmlhttprequest() or fetch() or some other modules directly in javascript policy ? I am getting error, If I define like bellow in javascript
var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
var xhr = new XMLHttpRequest();
Do I need to install and import packages for those from local to apigee cloud
You cannot do that.
There is no fetch or XMLHttpRequest available in the JS policy.
These also do not exist in nodejs. They are browser APIs. If you write JS code that runs in the browser, you can use such APIs. For JS code that runs on the server, those things don't exist.
There is an HTTP Client for the JS policy. Check the documentation to learn about it and see examples.