我有以下字符串并想提取代码的值。我使用了 split 函数,但它在 postman 中运行良好,但是当我在 newman 中执行相同的函数时,它会出错。
我想提取代码的值。在这种情况下是
EgxIZAAU3uHVt20pc9qqpv-xNcAWxitpB0vgMiulNLG2hkysukmjR04Fxxnuz9Yb
Run Code Online (Sandbox Code Playgroud)
我使用的代码是
var str= pm.response.headers.get('header1');
var str1= str.split('code=', 2)[1];
var code= str1.split('&', 2)[0]; // get the code
Run Code Online (Sandbox Code Playgroud)
它在邮递员中运行良好,但为什么纽曼在这里出错?
这对我有用:
let str = pm.response.headers.get("header1").split("code=")[1]
console.log(str.split("&")[0])
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1911 次 |
| 最近记录: |