我想在控制台中打印响应代码,但是我总是最终得到的响应为“ JSONError | No data,空输入为1:1”
在响应代码为204时出现此错误。否则条件正常。
脚本未达到条件。
请查看代码并提供解决方案。谢谢。
var respcode=pm.response.code;
var stagresbody=pm.response.json(responseBody);
if (respcode === 204) {
pm.test("engine is suspended with resposne code"+respcode,function(){
console.log(respcode);
})
}
else { pm.test("Staging is resumed with message"+stagresbody.serviceStatus,function(){
console.log("Staging is resumed with message "+stagresbody.serviceStatus);
});
}
答案 0 :(得分:0)
您可以使用它来做同样的事情:
if (pm.response.code === 204) {
pm.test(`Engine is suspended with resposne code ${pm.response.code}`, () => {
console.log(pm.response.code);
})
}
else {
pm.test(`Staging is resumed with message ${pm.response.json().stagresbody.serviceStatus}`, () => {
console.log(`Staging is resumed with message ${pm.response.json().stagresbody.serviceStatus}`);
});
}