pre-request script示例:
```javascript
const echoPostRequest = {
url: “http://” + ${pm.variables.get('host')}
+ “/api/v1/security/login”,
method: ‘POST’,
header: { ‘content-type’: ‘application/json’ },
body: {
mode: ‘raw’,
raw: JSON.stringify({“username”: “admin”, “password”: “123”, “provider”: “db”})
}
};
pm.sendRequest(echoPostRequest, function (err, res) { var jsonData = res.json(); if (err) { console.log(err); } else { console.info(jsonData) pm.environment.set(“access_token”, jsonData.access_token); } });