tencent cloud

BatchResponse
Last updated:2025-03-11 19:41:11
BatchResponse
Last updated: 2025-03-11 19:41:11
BatchResponse is the result obtained from batch-initiated HTTP requests using http.batch.

Field

Field
Type
Description
error
string
Error, which indicates a failed request if not left blank.
response
Response
Request result.

Samples

Initiate requests in batch and obtain results:
import http from 'pts/http';

export default function () {
const responses = http.batch(
[
{
method: 'GET',
url: 'http://httpbin.org/get?a=1',
headers: { a: '1, 2, 3' },
query: { b: '2' },
}
{
method: 'GET',
url: 'http://httpbin.org/get?a=1',
headers: { a: '1, 2, 3' },
query: { b: '2' },
}
]
{
parallel: 1,
}
);

// 200 OK
// 200 OK
for (const resp of responses) {
console.log(resp.response.status);
}
}


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

Feedback