7. Variables of postman

environment variable 

Environment variables As the name suggests, we can set variables for both the test environment and the production environment .

For example, we set the value of a variable in the test environment to be A, but the value of the production environment is B. At this time, the environment variable can be used . Of course, we can also change it manually without using the environment variable, but imagine that if this variable is used 10 times, and the value remains the same each time, if we manually change it, do we need to change it 10 times? So using environment variables can simplify things.

Example:

Interface address: https://www.v2ex.com/api/nodes/show.json?name=python

For example , the name value used in our test environment is python , and the name value used in the production environment is php , so how should we edit it?

 

Set test environment and production environment variables

Step 1: Click on the little eye and click edit in the Environment column

Step 2: Set the values ​​for the test environment and the production environment

 

 

 

 

 

Step 3: Use the variable values ​​of the test environment and production environment to test. Note here that 2 curly braces are required to refer to variables.

 

Step 4: View the running results

 

 

global variable

The setting method is similar to the environment variable

Step 1: Click on the little eye and click edit in the Globals column

 

 Step 2: Use global variables and see the results

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325260930&siteId=291194637