有奖捉虫:办公协同&微信生态&物联网文档专题 HOT
BatchOption 用于批量发起 HTTP 请求时的配置选项。

字段

字段
类型
描述
parallel?
number
可选,并行数,默认 20

使用样例

使用 BatchOption 进行批量请求的配置:
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' },
},
],
// BatchOption 配置选项
{
parallel: 1,
},
);
console.log(JSON.stringify(responses));
}