Postman external util library does not seem to load

I’m attempting to add some text encoding to a test script with the following code

var util = require("util");
var encoder = new util.TextEncoder();

which results in
TypeError: util.TextEncoder is not a constructor
using

var encoder = new TextEncoder(); // returns ReferenceError: TextEncoder is not defined
var encoder =util.TextEncoder; // works, but encoder is undefined

Any tips on what I might be doing wrong when referencing this library would be much appreciated

1 Like