【发布时间】:2020-11-18 00:53:43
【问题描述】:
我正在尝试使用在邮递员中运行按钮。我在文档 (https://learning.postman.com/docs/publishing-your-api/run-in-postman/run-button-API/) 中看到了有关如何编辑现有环境的说明。但我发现不清楚如何实现提供的代码。
我希望我的 run in postman 按钮根据从该按钮所在的页面发送的值具有不同的环境变量。本质上是根据 html 中的当前值编辑环境以具有值。
谁能解释文档中的这段代码在做什么以及它应该去哪里(也就是在 javascript 或邮递员测试中)?
来自邮递员文档 (https://learning.postman.com/docs/publishing-your-api/run-in-postman/run-button-API/):
更新环境的 API 密钥:
function () {
var stagingKey = document.getElementById('staging-key-input').value,
productionKey = document.getElementById('production-key-input').value,
preventOveride = true;
runButtonIndex = 0,
envData = {
stagingKey: stagingKey,
productionKey: productionKey
};
_pm('env.assign', 'API Keys', envData, preventOveride, runButtonIndex);
}
提前致谢!
【问题讨论】: