MCPcopy
hub / github.com/claude-code-best/claude-code / post

Function post

packages/weixin/src/api.ts:36–67  ·  view source on GitHub ↗
(
  baseUrl: string,
  path: string,
  body: unknown,
  token?: string,
  timeoutMs = 40_000,
  signal?: AbortSignal,
)

Source from the content-addressed store, hash-verified

34}
35
36async function post<T>(
37 baseUrl: string,
38 path: string,
39 body: unknown,
40 token?: string,
41 timeoutMs = 40_000,
42 signal?: AbortSignal,
43): Promise<T> {
44 const controller = new AbortController()
45 const timeout = setTimeout(() => controller.abort(), timeoutMs)
46
47 if (signal) {
48 signal.addEventListener('abort', () => controller.abort(), { once: true })
49 }
50
51 try {
52 const response = await fetch(`${baseUrl}${path}`, {
53 method: 'POST',
54 headers: buildHeaders(token),
55 body: JSON.stringify(body),
56 signal: controller.signal,
57 })
58
59 if (!response.ok) {
60 throw new Error(`HTTP ${response.status}: ${response.statusText}`)
61 }
62
63 return (await response.json()) as T
64 } finally {
65 clearTimeout(timeout)
66 }
67}
68
69export async function getUpdates(
70 baseUrl: string,

Callers 4

sendMessageFunction · 0.85
getUploadUrlFunction · 0.85
getConfigFunction · 0.85
sendTypingFunction · 0.85

Calls 3

fetchFunction · 0.85
buildHeadersFunction · 0.70
abortMethod · 0.65

Tested by

no test coverage detected