Review this AI-generated HTTP/2 batch client against its stated task.
Fetch a bounded list of JSON documents from one allowlisted origin over a reusable HTTP/2 session, carrying a bearer token and cleaning up every stream.
JavaScript
import { connect } from 'node:http2';
export async function fetchBatch(origin, paths, token) {
const session = connect(origin);
const requests = paths.map((path) =>
new Promise((resolve) => {
const request = session.request({
':method': 'GET',
':path': path,
connection: 'keep-alive',
authorization: `Bearer ${token}`,
});
let body = '';
request.on('data', (chunk) => (body += chunk));
request.on('end', () => resolve(JSON.parse(body)));
request.end();
}),
);
const results = await Promise.all(requests);
session.close();
return results;
}
generated code is illustrative, not from any one model