1、
<script>
let authorization = pm.environment.get("Authorization");
console.log("======= authorization " + authorization);
if (authorization != null) {
// 设置一个请求头
pm.request.headers.upsert({
key: 'Authorization', // 请求头名称
value: authorization// 请求头值
});
} else {
let cookie = pm.environment.get("Cookie");
console.log("======= cookie " + cookie);
if (cookie != null) {
// 设置一个请求头
pm.request.headers.upsert({
key: 'Cookie', // 请求头名称
value: cookie// 请求头值
});
}
}
</script>
标签:set,请求,null,cookie,pm,authorization,postman
From: https://www.cnblogs.com/kikyoqiang/p/18082141