Postman setting environment variables is simple and practical!

Preface

When we use postman to test the interface, a project often has multiple environments (testing, formal, etc.). The interface to request different environments is generally just that the ip and port are different. If only the environment is different, creating a new request will be more troublesome. At this time, we can define multiple environment variables and reference them in the interface address.

Create environment variables

1. Click the edit button in the upper right corner of postman (the red box in the upper right corner in the figure below), select add, and fill in the environment name, variable name, and corresponding variable value. There are multiple environments, just create multiple environments

Insert picture description here
2. After the addition is complete, we can select our environment in the Environment selection box. Below I select the newly added local_8083.
Insert picture description here
3. After selecting the environment variable, we can reference the variables in the environment. The reference method is: { {Variable name}}

Example:

{
    
    {
    
    host}}

Insert picture description here
For some common parameters, we can use this method to set up references, which can be easily used by us

Guess you like

Origin blog.csdn.net/qq_36551991/article/details/110571713