我在Postman中具有以下设置环境变量的Pre-request脚本
var current_timestamp = Date.now();
var current_timestamp = current_timestamp ;
var past = current_timestamp - 134;
postman.setEnvironmentVariable("current_timestamp", Number(current_timestamp));
postman.setEnvironmentVariable("past", Number(past));
这些变量在请求的正文中被引用:
{
"timestamps": [ "{{current_timestamp}}", "{{past}}"]
}
但是,变量保存为字符串,而不是整数。我想在请求正文中使用整数值。我尝试按照另一个答案中的建议在脚本中使用Number
,但它不会改变任何内容。
我该如何实现?
我必须删除双引号:{{current_timestamp}}
而不是"{{current_timestamp}}"
。