MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / post

Function post

src/services/utils/http.ts:90–107  ·  view source on GitHub ↗
(path: string, body?: unknown, signal?: AbortSignal)

Source from the content-addressed store, hash-verified

88}
89
90export async function post<T>(path: string, body?: unknown, signal?: AbortSignal): Promise<T> {
91 const hasBody = body !== undefined
92 const resp = await fetch(`${_baseUrl}${path}`, {
93 method: 'POST',
94 headers: {
95 ...getAuthHeaders(),
96 ...(hasBody && { 'Content-Type': 'application/json' }),
97 },
98 ...(hasBody && { body: JSON.stringify(body) }),
99 signal,
100 })
101 handle401(resp)
102 if (!resp.ok) {
103 const text = await resp.text().catch(() => '')
104 throw new Error(`HTTP ${resp.status}: ${text}`)
105 }
106 return resp.json() as Promise<T>
107}
108
109// ==================== 分析请求取消(epoch)====================
110//

Callers 15

reportErrorFunction · 0.90
clearMethod · 0.90
setDataDirMethod · 0.90
saveToDownloadsMethod · 0.90
openDirMethod · 0.90
showInFolderMethod · 0.90
addConfigMethod · 0.90
validateApiKeyMethod · 0.90
fetchRemoteModelsMethod · 0.90
addCustomProviderMethod · 0.90
addCustomModelMethod · 0.90
tryApplyOwnerProfileMethod · 0.90

Calls 3

getAuthHeadersFunction · 0.85
handle401Function · 0.85
textMethod · 0.80

Tested by

no test coverage detected