MCPcopy Create free account
hub / github.com/EvoMap/evolver / postJson

Function postJson

test/proxyTraceIntegration.test.js:16–43  ·  view source on GitHub ↗
(url, token, body)

Source from the content-addressed store, hash-verified

14}
15
16function postJson(url, token, body) {
17 return new Promise((resolve, reject) => {
18 const u = new URL(url);
19 const payload = JSON.stringify(body || {});
20 const req = http.request({
21 hostname: u.hostname,
22 port: u.port,
23 path: u.pathname,
24 method: 'POST',
25 headers: {
26 Authorization: 'Bearer ' + token,
27 'Content-Type': 'application/json',
28 'Content-Length': Buffer.byteLength(payload),
29 'x-api-key': 'sk-test',
30 },
31 }, (res) => {
32 const chunks = [];
33 res.on('data', (c) => chunks.push(c));
34 res.on('end', () => resolve({
35 status: res.statusCode,
36 body: Buffer.concat(chunks).toString(),
37 }));
38 });
39 req.on('error', reject);
40 req.write(payload);
41 req.end();
42 });
43}
44
45function readJsonl(file) {
46 return fs.readFileSync(file, 'utf8').trim().split('\n').map((line) => JSON.parse(line));

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected