I have below string and want to extract the value of code. I used split function but which runs fine in postman but when i execute same in newman it gives error.
I want to extract the value of code. which in this case is
EgxIZAAU3uHVt20pc9qqpv-xNcAWxitpB0vgMiulNLG2hkysukmjR04Fxxnuz9Yb
the code i am using is
var str= pm.response.headers.get('header1');
var str1= str.split('code=', 2)[1];
var code= str1.split('&', 2)[0]; // get the code
It worked fine in postman but why newman is giving error here?
This worked for me:
let str = pm.response.headers.get("header1").split("code=")[1]
console.log(str.split("&")[0])