BatchResponse 是利用 http.batch 批量发起 HTTP 请求得到的请求结果。
字段
字段 | 类型 | 描述 |
error | string | 错误,不为空则表示请求出错 |
response | 请求结果 |
样例
批量发起请求并获得结果:
import http from 'pts/http';export default function () {const responses = http.batch([{method: 'GET',url: 'http://mockhttpbin.pts.svc.cluster.local/get?a=1',headers: { a: '1, 2, 3' },query: { b: '2' },},{method: 'GET',url: 'http://mockhttpbin.pts.svc.cluster.local/get?a=1',headers: { a: '1, 2, 3' },query: { b: '2' },},],{parallel: 1,},);// 200 OK// 200 OKfor (const resp of responses) {console.log(resp.response.status);}}