How can I add jsonwebtoken as external lib for postman?

Viewed 24

From the following blog posts its possible to reference an external lib in postman

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?

0 Answers
Related