【发布时间】:2021-02-18 02:59:34
【问题描述】:
是否可以在先决条件脚本中更新邮递员请求的 url。 我想根据动态环境输入来编辑url。
例如:
if (environment.someValue) {
request.url = request.url + "\" + environment.someValue
if (environment.anotherValue) {
request.url = request.url + "\" + environment.anotherValue
}
}
console.log(request.url);
上面的代码给了我完美的控制台日志:
例如如果 url 是 https://someServer/someRequest,environment.someVar 是 x 和 environment.anotherVar 是 y console.log(request.url) 以上打印:
https://someServer/someRequest/x/y
但问题是(例如,如果我请求 Get),即使在记录了覆盖的请求 url 之后,它也只调用 https://someServer/someRequest 而不会覆盖到 https://someServer/someRequest/x/y。
关于如何修改上述网址的任何想法。
【问题讨论】:
标签: postman