postman 如何获得具体的响应Json?

o3imoua4  于 2023-01-09  发布在  Postman
关注(0)|答案(1)|浏览(198)
{
  "id": 115084015,
  "from": "help@email.ncloud.com",
  "subject": "Verify Code",
  "date": "2022-12-27 19:53:45",
  "attachments": ,
  "body": "  Verification Code : 9906 Enter the code to sign up!  Keep this code to yourself, and no other action is required. "
}

我想如何从json响应中获取提交的代码?
我只想获取要放入变量值的响应代码

aiazj4mn

aiazj4mn1#

我假设您希望从body部分获得9906

const res = pm.response.json();
let body = res.body;
const regex = /\d{4}/gm;

console.log(regex.exec(body)[0]);
//9906

相关问题