let a = (res) => new Function(pm.variables.get(res))
pm.sendRequest("https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.33/moment-timezone-with-data-2012-2022.min.js", (err, res) => {
pm.sendRequest("https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js", (err2, res2) => {
pm.environment.set("res2", res2.text());
pm.environment.set("res", res.text());
eval(pm.environment.get("res2"));
eval(pm.environment.get("res"));
console.log(this.moment.utc().tz("America/Los_Angeles", "UTC").format())
})
})
use min build instead as it wonβt mess up global space. you just have to call eval on the response to use it and then use this.
now to reuse the code you just have to use 
eval(pm.environment.get("res2"));
eval(pm.environment.get("res"));
console.log(this.moment.utc().tz("America/Los_Angeles", "UTC").format())
1 Like
Hi @praveendvd,
Just a thought, if we directly save the js data in global/collection/environment variable.
then can we use the eval function on that?
1 Like
Yes yes you can do that
, you just have trigger momentjs first to make moment timezone work
1 Like
Thanks, This worked for me. But copying the code gave me the wrong quotes and it added a 59 to the code.
worked for me AS-IS thanks
Hi all! Because this is still a highly viewed thread, I made a collection you can fork that shows a few different ways to import an external library. You can either pull a library directly from a CDN or load the contents of an external library into an environment variable. Either way, check out this collection to get started importing your favorite library today 
1 Like
any tips in using alasql ( https://cdnjs.com/libraries/alasql/0.6.2 ) ? I am getting alasql undefined property, both by setting it as an environment var or pm.sendRequest to the cdnjs repo. also tried using window = {} but still not able to.