Member-only story
Using external libraries in postman and there by using custom helper in Postman visualization!
2 min readJun 3, 2021
Postman allows you to use CDN libraries in the script session,
so here we are using the CDN equivalent of the handlebar and then passing the compiled template to the postman visualizer
**We can initialize CDN in two ways :**
**First Approach:**
By initializing the CDN in global space using “new Function(cdn)()”
You can see the code below , but this will mess up global scope and can be used only once in the entire run*
// you can call any package with min build in postman
pm.sendRequest("https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.7.7/handlebars.js", (err, res) => {pm.environment.set("res", res.text());
// intialize the min.js
new Function(pm.environment.get("res"))();//create template soource
var source =
`{{#ifCond v1 v2}}
{{v1}} is equal to {{v2}}
{{else}}
{{v1}} is not equal to {{v2}}
{{/ifCond}}`;//you can call methods in the cdn file using this keyword
//here we are registring handlebarHandlebars.registerHelper('ifCond', function (v1, v2, options) {
if (v1 ===…