postman multi-environment configuration token automatic login configuration

postman is a very useful tool, today to introduce his postman under multi-environment configuration token automatic login configuration

First, we would first look at the work of multi-platform model postman  create table test

Note: a multi-stage mode table corresponding to a program

 

Configure multiple environments  such as my local test points production environment

Fill variables, I used here not as a variable test, fill in the domain name corresponding to a good environment

 

Create a request to select a setting, in front of the interface you fill in variable configurations {{test}}, will automatically switch the domain name will help you

Multiple Environments done!

Configuring token automatically log  in to your login screen interface to select Tests enter the following script (you need to change according to their actual development, just an example)

pm.test("set token and sign", function () {
    let jsonData = pm.response.json();
    pm.expect(jsonData.code).to.eql(200);
    let token = jsonData.data.access_token
    pm.environment.set("token", "bearer " + token);
});

 

Enter the script

Select the top right corner of little eyes configure a global variable token_key (they can choose any name, note the use of the time to fill in just fine)

In the parameters you configure herders completed, the need for token interface look and found you can get the data, and the script has been automatically help you fill in the parameters of the environment inside

First here today, welcome attention to ocean technology blog  https://www.ypyunedu.com/article/93

Published 263 original articles · won praise 46 · views 370 000 +

Guess you like

Origin blog.csdn.net/qq_27229113/article/details/104921740