I have a pre-request-script in Postman which need to create URL:
var uri = new URL(request.url).pathname;
console.log("uri:" + uri);
Which failed with error: URL is not defined. I searched around and tried all different ways:
//const url = require('url');
//const URL = require('url').URL;
None of them work. I check node version and npm, it showed those are on installed
node -v
-bash: node: command not found
npm -v
-bash: npm: command not found
Do I have to install node for this to work?
I also run the code in chrome developer tool console, same result as undefined:
var uri = new URL(request.url).pathname
undefined
But in the same script I also use CryptoJS, which doesn't require any import, it just works.
I'm using macOS Mojave 10.14.6, and POSTMAN 7.21.2 app, not chrome extension.
pm.request.url = "My URL"
in the pre-request scripts. – Danny Dainton