postman设置全局变量

const accessKeyId = pm.environment.get('accessKeyId') || '8e6b43d0114c16372a0b15f057b54a88';
const accessKeySecret = pm.environment.get('accessKeySecret') || '0a90e826806fa1c919eb8d267c0154bfd167743e31b4ef0cabfbba084e8694c9';
const accessTime = new Date().getTime();

// 计算签名
const accessSign = CryptoJS.MD5(`${accessTime}_${accessKeySecret}`).toString()

// 给全局变量赋值
pm.globals.set('accessTime', accessTime);
pm.globals.set('accessKeyId', accessKeyId);
pm.globals.set('accessSign', accessSign);

console.log(`accessTime: ${accessTime};\naccessKeyId: ${accessKeyId};\naccessSign: ${accessSign};`);

 

posted @ 2023-02-13 13:41  稻火  阅读(104)  评论(0编辑  收藏  举报