MCPcopy Create free account
hub / github.com/cloudflare/computer / postJson

Function postJson

packages/computerd/src/cli/computerd.test.ts:487–514  ·  view source on GitHub ↗
(url, body)

Source from the content-addressed store, hash-verified

485}
486
487function postJson(url, body) {
488 const payload = JSON.stringify(body);
489 return new Promise((resolve, reject) => {
490 const req = http.request(
491 url,
492 {
493 method: "POST",
494 headers: {
495 "content-type": "application/json",
496 "content-length": Buffer.byteLength(payload),
497 },
498 },
499 (response) => {
500 response.setEncoding("utf8");
501 let buf = "";
502 response.on("data", (chunk) => {
503 buf += chunk;
504 });
505 response.on("end", () => {
506 resolve({ body: buf, headers: response.headers, statusCode: response.statusCode });
507 });
508 },
509 );
510 req.once("error", reject);
511 req.write(payload);
512 req.end();
513 });
514}
515
516function stopProcess(child) {
517 return new Promise((resolve, reject) => {

Callers 1

connectFunction · 0.85

Calls 2

writeMethod · 0.65
endMethod · 0.65

Tested by

no test coverage detected