Field | Type | Description |
body | string | The response returned by the server. |
contentLength | number | The length of the server response body. |
headers | Record<string, string> | The HTTP headers of the server response. |
proto | string | Protocol, such as "HTTP/1.0". |
request | The request sent to obtain this response. | |
responseTimeMS | number | The response time of the request in milliseconds. |
status | string | The HTTP status message from the server response, such as "200 OK". |
statusCode | number | The HTTP status code from the server response, such as "200". |
Methodology | Return Type | Description |
any | Deserialize Response.body to json. |
import http from 'pts/http';export default function () {const req = {method: 'post',url: 'http://httpbin.org/post',headers: { 'Content-Type': 'application/json' },query: { a: '1' },body: { user_id: '12345' },};const resp = http.do(req);console.log(resp.json()); // [Object object]console.log(resp.json().args.a); // 1console.log(resp.json().json.user_id); // 12345}