1、
<script>
let authorization = pm.environment.get("Authorization");
console.log("======= authorization " + authorization);
if (authorization != null && authorization !== "") {
// 设置一个请求头
pm.request.headers.upsert({
key: 'Authorization', // 请求头名称
value: authorization// 请求头值
});
} else {
let cookie = pm.environment.get("Cookie");
console.log("======= cookie " + cookie);
if (cookie != null && cookie !== "") {
// 设置一个请求头
pm.request.headers.upsert({
key: 'Cookie', // 请求头名称
value: cookie// 请求头值
});
}
}
</script>