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

Function patch

src/services/utils/http.ts:178–194  ·  view source on GitHub ↗
(path: string, body?: unknown)

Source from the content-addressed store, hash-verified

176}
177
178export async function patch<T>(path: string, body?: unknown): Promise<T> {
179 const hasBody = body !== undefined
180 const resp = await fetch(`${_baseUrl}${path}`, {
181 method: 'PATCH',
182 headers: {
183 ...getAuthHeaders(),
184 ...(hasBody && { 'Content-Type': 'application/json' }),
185 },
186 ...(hasBody && { body: JSON.stringify(body) }),
187 })
188 handle401(resp)
189 if (!resp.ok) {
190 const text = await resp.text().catch(() => '')
191 throw new Error(`HTTP ${resp.status}: ${text}`)
192 }
193 return resp.json() as Promise<T>
194}

Callers 3

savePreferencesMethod · 0.90
saveUiConfigMethod · 0.90
saveLocaleMethod · 0.90

Calls 3

getAuthHeadersFunction · 0.85
handle401Function · 0.85
textMethod · 0.80

Tested by

no test coverage detected