mpr*_*rad 2 client http intellij-idea
在响应处理部分
如果下面是总体响应
[
{
"empId":1001,
"empName":"abc"
},
{
"empId":1002,
"empName":"xyz"
}
]
Run Code Online (Sandbox Code Playgroud)
我能够得到这个回应
> {%
console.log(response.body);
%}
Run Code Online (Sandbox Code Playgroud)
有没有办法将此响应写入本地文件系统上的文件?此外,我们似乎只能访问客户端和响应对象。我们还可以写for循环等控制结构吗?
小智 6
You can redirect a response to a file. Use >> to create a new file with a suffix if it already exists and >>! to rewrite the file if it exists. You can specify an absolute path or relative to the current HTTP Request file. You can also use variables in paths, including environment variables and the following predefined variables:
{{$projectRoot}} points to the project root: .idea
{{$historyFolder}} points to .idea/httpRequests/
The following example HTTP request creates myFile.json in myFolder next to the HTTP Request file and redirects the response to it. If the file already exists, it creates myFile-1.json and so on.
POST https://httpbin.org/post
Content-Type: application/json
{
"id": 999,
"value": "content"
}
>> myFolder/myFile.json
Run Code Online (Sandbox Code Playgroud)
ref:
| 归档时间: |
|
| 查看次数: |
7028 次 |
| 最近记录: |