PostMan set a global variable

Disclaimer: This article is a blogger original article, reproduced, please indicate the source of the article. https://blog.csdn.net/SunFlowerInRain/article/details/81977481

To set a global variable postMan

1. curly brackets can be realized by reference to the variable {{}};
2. set a global variable needs to be well disposed inside in the Test request:

let json = JSON.parse(responseBody);//声明一个变量json,将JSON返回Body里面的值解析并给变量json
tests["a"] = responseBody.has("0");//设置一个断言
pm.globals.set("token", json.token);//获取js

3. The results of the testResult see them printed, PASS the test passed, otherwise it will error;
4. Call to the place of use;

Guess you like

Origin blog.csdn.net/SunFlowerInRain/article/details/81977481