MCPcopy Create free account
hub / github.com/CopilotKit/aimock / httpPost

Function httpPost

src/__tests__/request-transform.test.ts:26–49  ·  view source on GitHub ↗
(url: string, body: object)

Source from the content-addressed store, hash-verified

24}
25
26async function httpPost(url: string, body: object): Promise<{ status: number; body: string }> {
27 return new Promise((resolve, reject) => {
28 const req = http.request(
29 url,
30 {
31 method: "POST",
32 headers: { "Content-Type": "application/json" },
33 },
34 (res) => {
35 const chunks: Buffer[] = [];
36 res.on("data", (c) => chunks.push(c));
37 res.on("end", () =>
38 resolve({
39 status: res.statusCode!,
40 body: Buffer.concat(chunks).toString(),
41 }),
42 );
43 },
44 );
45 req.on("error", reject);
46 req.write(JSON.stringify(body));
47 req.end();
48 });
49}
50
51/** Strip ISO timestamps from text content. */
52const stripTimestamps = (req: ChatCompletionRequest): ChatCompletionRequest => ({

Callers 1

Calls 4

resolveFunction · 0.85
onMethod · 0.80
writeMethod · 0.80
endMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…