use*_*675 2 postman postman-pre-request-script
我正在尝试获取预请求脚本中的 cookie,以将其与其他请求链接起来,该请求使用下面的示例作为空数组返回。
在最新版本的 postman v8 中,无法使用 pm.sendRequest 获取 cookies 对象,否则该对象可以在低于 8 的 postman 版本中工作。
pm.sendRequest(url, function (err, response, { cookies }) {
console.log(cookies.all());
});Run Code Online (Sandbox Code Playgroud)
我想你可能需要这样的东西来查看cookie:
pm.sendRequest("https://postman-echo.com/get", function (err, response, options) {
console.log(options.cookies.members);
});
Run Code Online (Sandbox Code Playgroud)
从这里您可以循环遍历members数组以获得您需要的内容。
| 归档时间: |
|
| 查看次数: |
1668 次 |
| 最近记录: |