MCPcopy
hub / github.com/elysiajs/elysia / post

Function post

test/utils.ts:46–67  ·  view source on GitHub ↗
(path: string, body?: string | Record<string, any>)

Source from the content-addressed store, hash-verified

44}
45
46export const post = (path: string, body?: string | Record<string, any>) =>
47 typeof body === 'string'
48 ? new Request(`http://localhost${path}`, {
49 method: 'POST',
50 headers: {
51 'Content-Type': 'text/plain',
52 'Content-Length': String(Buffer.byteLength(body))
53 },
54 body
55 })
56 : new Request(`http://localhost${path}`, {
57 method: 'POST',
58 headers: body
59 ? {
60 'Content-Type': 'application/json',
61 'Content-Length': String(
62 Buffer.byteLength(JSON.stringify(body))
63 )
64 }
65 : {},
66 body: body ? JSON.stringify(body) : body
67 })
68
69export const delay = (delay: number) =>
70 new Promise((resolve) => setTimeout(resolve, delay))

Callers 15

macro.test.tsFile · 0.90
error.test.tsFile · 0.90
parser.test.tsFile · 0.90
date.test.tsFile · 0.90
union-enum.test.tsFile · 0.90
normalize.test.tsFile · 0.90
sanitize.test.tsFile · 0.90
dynamic.test.tsFile · 0.90
detail.test.tsFile · 0.90
timing.test.tsFile · 0.90
body.test.tsFile · 0.90
response.test.tsFile · 0.90

Calls

no outgoing calls

Tested by 1

fromFunction · 0.72