如何使用idea的http client完成全局变量的缓存

response.body的示例值,具体根据业务而定

{
  "success": true,
  "message": null,
  "content": {
    "id": 1677945480585285632,
    "mobile": "12321",
    "token": "xxxxxxxxxxxxxxxxxxxxxxx"
  }
}

登入并将token保存到全局变量中方中

POST {{GATEWAY}}/member/member/login
Content-Type: application/json

{
  "mobile": 12321,
  "code": 6666
}

> {%
    client.global.set("token", response.body.content.token);
%}

使用全局变量的值

### 在请求头里带上全局变量token的值
POST {{GATEWAY}}/member/passenger/save
Content-Type: application/json
token: {{token}}

{
  "memberId": 1677945480585285632,
  "name": "张三",
  "idCard": 123456789,
  "type": 3
}

你可能感兴趣的:(intellij-idea,http,缓存)