tencent cloud

Response.json
Last updated: 2025-03-11 19:41:12
Response.json
Last updated: 2025-03-11 19:41:12
Response.json deserializes Response.body to json.
json(): any

Return

Type
Description
any
Return an object representing Response.body.

Samples

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); // 1
console.log(resp.json().json.user_id); // 12345
}

Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback