From the following blog posts its possible to reference an external lib in postman
- https://blog.postman.com/adding-external-libraries-in-postman/
- https://community.postman.com/t/adding-external-libraries-to-postman/1971/3
However if I attempt this with jsonwebtoken it does not work as that lib references its own files.
pm.sendRequest("https://cdnjs.cloudflare.com/ajax/libs/jsonwebtoken/8.5.1/sign.min.js", (err, res) => {
//convert the response to text and save it as an environment variable
pm.collectionVariables.set("jsonwebtoken_library", res.text());
// eval will evaluate the JavaScript code and initialize the min.js
eval(pm.collectionVariables.get("jsonwebtoken_library"));
// you can call methods in the cdn file using this keyword
console.log(this.sign({ foo: 'bar' }, 'shhhhh'))
})
Error is always
Error: Cannot find module './lib/timespan'
How can jsonwebtoken be used as an external lib on postman?