POSTMAN | if语句的GET变量

时间:2017-03-20 09:18:49

标签: postman

我想在邮差中做一个if语句。我有Environmet变量:server_state1& server_state2 这些变量都得到0-3的数字。 现在我想在PUT声明中写一个预请求脚本。 IF声明听起来像是

var server_state1 = postman.GetEnvironmentVariable("state_server1");
var server_state2 = postman.GetEnvironmentVariable("state_server2");

if (server_state1 === 0 && server_state2 === 0){
   postman.SetEnvironmentVariable("server_state12", "Everything is fine");
}

但这不起作用。

2 个答案:

答案 0 :(得分:4)

答案是:

var server_state1 = postman.GetEnvironmentVariable("state_server1");
var server_state2 = postman.GetEnvironmentVariable("state_server2");

if (server_state1 === "0" && server_state2 === "0"){
postman.SetEnvironmentVariable("server_state12", "Everything is fine");
}

答案 1 :(得分:1)

您正在寻找的功能在lowerCamelCase中定义。

尝试使用:

postman.getEnvironmentVariable("state_server1")
postman.setEnvironmentVariable("server_state12", "Everything is fine");

而不是:

postman.GetEnvironmentVariable("state_server1");
postman.SetEnvironmentVariable("server_state12", "Everything is fine");